I'm calling a web service using AFNetworking
and saving the return data in NSDictionary
object. But nothing's being stored in it, even when data is successfully logged in NSLog()
.
This is my dictionary:
@property (strong, nonatomic) NSDictionary *newsItems;
and this is my codes:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"key": @"keyy", @"q": @"ads" };
[manager POST:BaseURLString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.newsItems = (NSDictionary *) responseObject;
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
First, check whether you're getting any response from web service using the below line:
NSLog(@"RESPONSE : %@", operation.responseString);
Second, if your web service is supposed to return an array of dictionaries, then you should declare an array instead on dictionary.
@property (strong, nonatomic) NSArray *newsItems;
instead of
@property (strong, nonatomic) NSDictionary *newsItems;