iphone - Objc_msgSend and app crash -
when trying launch app on simulator (3.1.3 , xcode 3.1.4), shows me objc_msgsend , application not launch. happens when alloc nsmutable array code part, in viewdidload,
-(void)viewdidload{ locationarray = [[nsmutablearray alloc] initwithobjects:@"new delhi", @"faridabad",@"meerut"]; str1=[locationarray objectatindex:0]; str2=[locationarray objectatindex:1]; [super viewdidload]; }
then want use locationarray objects in following method;
-(cllocationcoordinate2d) addresslocation1{ double latitude = 0.0; double longitude = 0.0; nsstring *str= [locationarray nsstring *str= [locationarray objectatindex:0]; //nsstring *str= @"new delhi" nsstring *urlstring = [nsstring stringwithformat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [str stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; nsstring *locationstring = [nsstring stringwithcontentsofurl:[nsurl urlwithstring:urlstring]]; nsarray *listitems = [locationstring componentsseparatedbystring:@","]; if([listitems count] >= 4 && [[listitems objectatindex:0] isequaltostring:@"200"]) { latitude = [[listitems objectatindex:2] doublevalue]; longitude = [[listitems objectatindex:3] doublevalue]; } else { //show error } cllocationcoordinate2d location; location.latitude = latitude; location.longitude = longitude; return location; }
problem occur when alloc locationarray, whats wrong me, please thanks
locationarray = [[nsmutablearray alloc] initwithobjects:@"new delhi", @"faridabad",@"meerut"];
try
locationarray = [[nsmutablearray alloc] initwithobjects:@"new delhi", @"faridabad",@"meerut", nil];
from the nsarray docs see initwithobjects:
requires termination nil
. if don't want that, , know how many have, can use initwithobjects:count:
Comments
Post a Comment