This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)getNextMessages:(NSNumber *)maxMessageId { | |
if (!self.flakManager.isLoggedIn) { | |
[self createSession]; | |
} | |
// NSLog(@"In getNextMessages: %@", maxMessageId); | |
NSString *urlString = [NSString | |
stringWithFormat:@"%@/messages.json?kind=message&after_id=%@", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark NSURLConnection Delagate Callback Methods | |
- (void)connection:(NSURLConnection *)connection | |
didReceiveResponse:(NSURLResponse *)response { | |
NSLog(@"In didReceiveResponse"); | |
self.responseString = @""; | |
} | |
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deserialize json and add to Core Data | |
- (void)processNewMessagesData:(NSString *)jsonMessages { | |
NSLog(@"In processNewMessagesData"); | |
NSData *messagesData = [jsonMessages dataUsingEncoding:NSUTF8StringEncoding]; | |
NSError *error = nil; | |
NSArray *messageArray = [[CJSONDeserializer deserializer] | |
deserialize:messagesData error:&error]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to poll | |
// Property | |
NSTimer *keepLoggedInTimer; | |
// Methods | |
- (void)keepLoginAlive:(NSTimer *)timer; | |
- (void)startTimerForKeepAlive; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/user/Library/Application\ Support/iPhone\ Simulator/User/Applications |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add a message to Core Data | |
- (void)addMessage:(NSDictionary *)newMessageDictionary { | |
NSDictionary *messageDictionary = [newMessageDictionary objectForKey:@"message"]; | |
// NSLog(@"In addMessage"); | |
// NSLog(@"new message dictionary:\n%@", newMessageDictionary); | |
NSEntityDescription *entity = | |
[self.messageFetchedResultsController.fetchRequest entity]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Application Data Initialization | |
- (void)awakeFromNib { | |
// NSLog(@"waking up!"); | |
[self managedObjectContext]; | |
self.hostURL = @"http://flak.heroku.com"; | |
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; | |
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Escape double quotes in new messages | |
-(NSString *)escapeString:(NSString *)string { | |
NSString *cleanString = [string stringByReplacingOccurrencesOfString:@"\"" | |
withString:@"\\\""]; | |
return cleanString; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//NSUserDefaults usage for user and app settings | |
- (void)createUserDefaultsFromPlist { | |
NSString *settingsPlistPath = [[NSBundle mainBundle] | |
pathForResource:@"FlakSettings" ofType:@"plist"]; | |
NSDictionary *dictionaryFromDefaultPlist; | |
if (settingsPlistPath) { | |
dictionaryFromDefaultPlist = [NSMutableDictionary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//POSTing a message to the server and checking the response. | |
//POST the message to the server | |
NSData *responseData = [NSURLConnection sendSynchronousRequest:request | |
returningResponse:&response error:&error]; | |
//Extract the JSON string from the response | |
NSString *jsonString = [[NSString alloc] initWithData:responseData | |
encoding:NSUTF8StringEncoding]; |
OlderNewer