I'm using JSONModel to retrieve data from a simple webservice. I need to get the values of key @"message"
into a mutable array.
- (void)viewDidLoad
{
[super viewDidLoad];
self.delegate = self;
self.dataSource = self;
NSString *conversationid = @"xx";
NSString *callURL = [NSString stringWithFormat:@"http://mydomain.com/inbox_messages.php?conversation=%@", conversationid];
_feed = [[MessageFeed alloc] initFromURLWithString:callURL
completion:^(JSONModel *model, JSONModelError *err)
{
self.messages = [[NSMutableArray alloc]initWithObjects:[_feed.messagesinconversation valueForKey:@"message"], nil];
NSLog(@"messages %@", self.messages);
}];
NSLog(@"test %@", self.messages);
}
The problem I'm experiencing is that while: NSLog(@"messages %@", self.messages);
returns all the right data, NSLog(@"test %@", self.messages);
returns (null)
.
The variable is declared in .h of my class as: @property (strong, nonatomic) NSMutableArray *messages;
This is probably a noob question but I'm a beginner and if somebody could give me a pointer in the right direction, I would be very happy.