diff options
Diffstat (limited to 'Juick/Message.m')
-rw-r--r-- | Juick/Message.m | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Juick/Message.m b/Juick/Message.m index e87834b..08f9289 100644 --- a/Juick/Message.m +++ b/Juick/Message.m @@ -27,4 +27,25 @@ return result; } ++(NSArray *) pullNextFromURL:(NSURL *)url { + // Set the gesture + NSError *error; + NSString *data = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; + if (data == nil) { + NSLog(@"Download Error: %@", error); + return nil; + } + NSArray *resultObject = [NSJSONSerialization JSONObjectWithData:[data dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error]; + if (resultObject == nil) { + NSLog(@"JSON Error: %@", error); + return nil; + } + NSMutableArray *result = [NSMutableArray array]; + for (NSDictionary *message in resultObject) { + Message *msg = [[Message alloc] initWithDictionary:message]; + [result addObject:msg]; + } + return [result copy]; +} + @end |