Reputation: 1
- (void)viewDidLoad
{
binding.logXMLInOut = YES; // to get logging to the console.
StationDetailsJsonSvc_getAvailableStations *request = [[StationDetailsJsonSvc_getAvailableStations new] autorelease];
request.userName=@"twinkle";
request.password=@"twinkle";
StationDetailsJsonSoap11BindingResponse *resp = [binding getAvailableStationsUsingParameters:request];
for (id mine in resp.bodyParts)
{
if ([mine isKindOfClass:[StationDetailsJsonSvc_getAvailableStationsResponse class]])
{
resultsring = [mine return_];
NSLog(@"list string is%@",resultsring);
}
}
#pragma mark parsing
SBJsonParser *parserq = [[SBJsonParser alloc] init];
//if successful, i can have a look inside parsedJSON - its worked as an NSdictionary and NSArray
results= [parserq objectWithString:resultsring error:nil];
NSLog(@"print %@",results);
for (status in results)
{
NSLog(@"%@ ",[status objectForKey:@"1" ]);
events=[status objectForKey:@"1"];
NSLog(@"get%@",events);
NSLog(@"events%@",events);
}
events=[status objectForKey:@"1"];
NSLog(@"post%@",events);
self.navigationController.navigationBarHidden=YES;
[whethertableview reloadData];
[super viewDidLoad];
}
this is my code am not getting tableview contents if i run my app crashes getting [NSCFString count]:unrecognized selector sent to instance
Upvotes: 0
Views: 1772
Reputation: 26972
There are various improvements you could make with this code, but I think I see the problem:
As you are not using ARC, you need to retain what you take out of the parser:
So instead of:
events=[status objectForKey:@"1"]
You need to do:
events= [[status objectForKey:@"1"] retain];
Your crash is caused by accessing a variable that has already been released. More than likely it is the events variable.
...and to add to this. events is probably an NSArray which 'count' is being called on. And [status objectForKey:@"1"] is returning a string... there are many possibilities which i'm speculating about. If events is an NSArray, this isn't the way to add objects to the array.. you repeatedly call events=[status objectForKey:@"1"]; in a loop too.
Upvotes: 0
Reputation: 6166
You should not get count on NSString
but on arrays
you should call [yourString length]
to check if the string has something.
You are trying to get the count of a string , which is crashing the App
Upvotes: 1