osx - Use of undeclared identifier Objective-C Code -
i new objective-c coding ,please bear me ask if simple question
my header file:
#import <cocoa/cocoa.h> @interface appdelegate : nsobject <nsapplicationdelegate> @property (assign) iboutlet nswindow *window; @end
my implementation file:
#import "appdelegate.h" @implementation appdelegate - (void)applicationdidfinishlaunching:(nsnotification *)anotification { // insert code here initialize application // listing 2-1 creating connection using nsurlconnection // create request. nsurlrequest *therequest=[nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://www.apple.com/"] cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:60.0]; // create nsmutabledata hold received data. // receiveddata instance variable declared elsewhere. receiveddata = [nsmutabledata datawithcapacity: 0]; // create connection request // , start loading data nsurlconnection *theconnection=[[nsurlconnection alloc] initwithrequest:therequest delegate:self]; if (!theconnection) { // release receiveddata object. receiveddata = nil; // inform user connection failed. } } @end
at receiveddata
in implementation file showing undeclared identifier. if declare variable in .h file saying cannot declare variable inside @interface , protocol
as can see in comment:
// receiveddata instance variable declared elsewhere. receiveddata = [nsmutabledata datawithcapacity: 0];
receiveddata should declared somewhere. try this:
nsmutabledata *receiveddata = [nsmutabledata datawithcapacity: 0];
Comments
Post a Comment