From 6dfbafe71aba41bdcf8aba331c1c193c88b42561 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 3 Nov 2013 04:38:05 +0400 Subject: Pull to refresh and infinite scrolling --- Juick/Message.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Juick/Message.m') 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 -- cgit v1.2.3