I am working with a UITableViewController. The method that fails is:
- (void) testLoc {
self.dictionary = [self.delegate getLocationsWithLatitude:@"0.0" longitude:@"0.0"]; //HERE
[self setUpTableArray:dictionary];
}
Test results have shown that the exception is thrown in the first line of testLoc
.
- (NSDictionary *) getLocationsWithLatitude:(NSString *)latitude longitude:(NSString *)longitude;
All I do in the above method is make an HTTP request and return an NSDictionary.
Below is my viewDidLoad (the first method call, which works) for the UITableViewController:
- (void)viewDidLoad {
self.delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self testLoc];
[super viewDidLoad];
}
And here is my viewWillAppear, which I get "unrecognized selector" from:
- (void)viewWillAppear:(BOOL)animated {
self.delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self testLoc];
[super viewWillAppear:animated];
}
Here is the error that I am getting:
-[NSCFString key]: unrecognized selector sent to instance 0x141770
The reason I am doing this is because I have a table view that I want to update every time I tab back to it with a tab bar.
This is for the first real app that I am building, and I would really appreciate any kind of insight. Thanks!!
UPDATE
Here is getLocationsWithLatitude:
- (NSDictionary *) getLocationsWithLatitude:(NSString *)latitude longitude:(NSString *)longitude {
OAMutableURLRequest *locationsRequest = [[OAMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://somerequesturl"]
consumer:self.globals.consumer
token:self.globals.requestToken
realm:nil signatureProvider:nil];
[locationsRequest setHTTPMethod:@"GET"];
[locationsRequest setParameters:[NSArray arrayWithObjects:
[OARequestParameter requestParameter:@"geolat" value:latitude],
[OARequestParameter requestParameter:@"geolong" value:longitude],
nil]];
[locationsRequest prepare];
NSData *locationsData = [NSURLConnection sendSynchronousRequest:locationsRequest returningResponse:nil error:nil];
NSString *locationsString = [[[NSString alloc] initWithData:locationsData encoding:NSUTF8StringEncoding] autorelease];
[locationsRequest release];
SBJSON *jsonParser = [SBJSON new];
NSError *error = nil;
return [jsonParser objectWithString:locationsString error:&error];
}
Here is setUpTableArray:
- (void) setUpTableArray:(NSDictionary *)dict {
NSArray *array = [dict objectForKey:@"groups"];
if (array != nil) {
self.placesArray = array;
}
}