ios - use of undeclared identifier objective-c -


i getting use of undeclared identifier 'data' in didreceiveresponse method. have imported model header file has array , data declared. found if declare them inside viewcontroller.h file error goes away. cause of problem?

    #import "viewcontroller.h"     #import "detailviewcontroller.h"     //#import "model.h"     #import "model.h"      @interface viewcontroller ()      @end      @implementation viewcontroller      - (void)viewdidload {         [super viewdidload];          [uiapplication sharedapplication].networkactivityindicatorvisible = yes;          nsurl *url = [nsurl urlwithstring:@"https://s3.amazonaws.com/jon-hancock-phunware/nflapi-static.json"];          nsurlrequest *request = [nsurlrequest requestwithurl:url];          [[nsurlconnection alloc] initwithrequest:request delegate:self];          // additional setup after loading view, typically nib.     }      - (void)didreceivememorywarning {         [super didreceivememorywarning];         // dispose of resources can recreated.     }      - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response {          data = [[nsmutabledata alloc]init];      } 

this model header file.

#import <uikit/uikit.h>  @interface model : uiviewcontroller      //nsarray *bars;     //nsmutabledata *data;    @property (nonatomic, retain) nsarray *bars; @property (nonatomic, retain) nsmutabledata *data;  @end 

this fixes error defining variables inside viewcontroller.h file.

import

@interface viewcontroller : uiviewcontroller {      iboutlet uitableview *maintableview;     nsarray *bars;     nsmutabledata *data;  } @end 

it's objective-c not swift. access properties self.data or _data. doesn't know enough global variables unless you're explicit it. also, lean towards self.data on directly accessing _data setter gets called. in case, it's not going issue setting ivars directly underscore can mess key value observation , might have unexpected consequences difficult debug.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -