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)handleEvent:(NSDictionary *)json { | |
NSData *data = [json[@"json"] dataUsingEncoding:NSUTF8StringEncoding]; | |
NSString *type = json[@"event_type"]; | |
NSDictionary *object = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]; | |
if ([type isEqualToString:@"new_tweet"]) { | |
[self handleNewTweet:object]; | |
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
#define kBrowserPref @"browserPref" | |
- (IBAction)openInBrowserButtonPressed:(id)sender { | |
NSString *myURL = nil; // put however you get the URL here | |
// can we open in Chrome? | |
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"googlechrome:"]]) { | |
// let's check the preference |
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)multipartPost:(NSString *)path postParams:(NSDictionary *)postParams success:(void (^)(id object))successHandler | |
failure:(void (^)(NSHTTPURLResponse*, NSData*, NSError*))failureHandler NS_AVAILABLE(10_7, 5_0) { | |
NSString *boundary = @"----------------------------ToOdOiPhOnEaPp"; | |
NSMutableURLRequest *request = [self postRequest:path]; | |
NSString *contentType = $S(@"multipart/form-data, boundary=%@", boundary); | |
[request setValue:contentType forHTTPHeaderField:@"Content-type"]; | |
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)get { | |
[RSServer get:nil completionBlock:^(CKResult *result) { | |
NSLog(@"server get response code %i: %@", result.responseCode, [[NSString alloc] initWithData:result.responseBody encoding:NSUTF8StringEncoding]); | |
if ([result isSuccess]) { | |
// We should remove servers that didn't come back in the results. | |
// To do this, we need to find the complement to the result set and |
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
- (id) serialize:(id) object{ | |
NSData *value = nil; | |
id serializedObject = nil; | |
if ([object isKindOfClass:[CKRecord class]]) { | |
CKRecord *record = (CKRecord *)object; | |
NSMutableDictionary *jsonDictionary = [[NSMutableDictionary alloc] init]; | |
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
RSServer *server = [RSServer blank]; | |
server.name = @"ck-test"; | |
server.flavorId = [[RSFlavor first] id]; | |
server.imageId = [[RSImage first] id]; | |
[server post:nil completionBlock:^(CKResult *result) { | |
if ([result isSuccess]) { | |
[self alert:@"success!"]; |
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)rebuildWithImage:(RSImage *)image success:(CKBasicBlock)successBlock failure:(void (^)(CKResult *result))failureBlock { | |
CKRequest *request = [self actionRequest]; | |
[request setBodyWithJSONDict:$D($D(image.id, @"imageId"), @"rebuild")]; | |
[self send:request success:successBlock failure:failureBlock]; | |
} |
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
- (CKRequest *)actionRequest { | |
// TODO: self.id needs to be a string instead of an int | |
CKRequest *request = [CKRequest requestWithRemotePath:$S(@"/servers/%@/action", self.id)]; | |
NSLog(@"request url: %@", request.remoteURL); | |
request.method = CKRequestMethodPOST; | |
[request addHeaders:[NSDictionary dictionaryWithObject:[[RSAccount activeAccount] api_auth_token] forKey:@"X-Auth-Token"]]; | |
return request; | |
} |
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
// | |
// RSAccountsDataSource.m | |
// Rackspace | |
// | |
// Created by Michael Mayo on 9/27/11. | |
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved. | |
// | |
#import "RSAccountsDataSource.h" | |
#import "RSAccount.h" |
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
// | |
// RSAccountsViewController.m | |
// Rackspace | |
// | |
// Created by Michael Mayo on 9/27/11. | |
// Copyright (c) 2011 Rackspace, US Inc. All rights reserved. | |
// | |
#import "RSAccountsViewController.h" | |
#import "RSAccountsDataSource.h" |
NewerOlder