This file contains hidden or 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)populateWithRetiredHeroesIfEmpty | |
| { | |
| if (self.heroes.count < 2) { | |
| for (RetiredSuperhero *retiredSuperhero in self.retiredSuperheroes) { | |
| NSManagedObject *superhero = [NSEntityDescription insertNewObjectForEntityForName:@"Superhero" inManagedObjectContext:self.moc]; | |
| [superhero setValue:retiredSuperhero.name forKey:@"name"]; | |
| [superhero setValue:retiredSuperhero.textDescription forKey:@"textDescription"]; | |
| [superhero setValue:retiredSuperhero.urlString forKey:@"imageURL"]; | |
| [self.moc save:nil]; | |
| [self load]; |
This file contains hidden or 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)testFirstSuperHero { | |
| XCTestExpectation *expectation = [self expectationWithDescription:@"Retrieving Superheroes"]; | |
| [SuperHero retrieveSuperHerosWithCompletion:^(NSArray *superHeros) { | |
| SuperHero *firstHero = superHeros.firstObject; | |
| NSLog(@"%@", firstHero.name); | |
| XCTAssertEqualObjects(firstHero.name, @"Namor"); | |
| [expectation fulfill]; | |
| }]; |
This file contains hidden or 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
| - (NSURL *)applicationDocumentsDirectory { | |
| NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]); | |
| // The directory the application uses to store the Core Data store file. This code uses a directory named "yourname.BookClub" in the application's documents directory. | |
| return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; | |
| } |
This file contains hidden or 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
| if error == nil | |
| { | |
| let mostRecentMessage = self.messages.first | |
| var indexPathArray = [NSIndexPath]() | |
| var index = 0 | |
| for tweet in tweetMessages | |
| { | |
| //If any new tweets are found, add them to the array | |
| if tweet.bornOn!.compare(mostRecentMessage!.bornOn!) == NSComparisonResult.OrderedDescending | |
| { |
This file contains hidden or 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
| var indexPathArray = [NSIndexPath]() | |
| var index = 0 | |
| for message in messages { | |
| self.messages.insert(message, atIndex: index) | |
| indexPathArray.insert(NSIndexPath(forItem: index, inSection: 0), atIndex: index) | |
| index++ | |
| } | |
| self.collectionView.insertItemsAtIndexPaths(indexPathArray) |
This file contains hidden or 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
| // | |
| // ViewController.m | |
| // PTKPayment Example | |
| // | |
| // Created by Alex MacCaw on 1/21/13. | |
| // Copyright (c) 2013 Stripe. All rights reserved. | |
| // | |
| #import "UpdateCardViewController.h" | |
| #import "Stripe.h" |
This file contains hidden or 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
| // | |
| // PPDataManager.swift | |
| // HealthBuddy | |
| // | |
| // Created by Vik Denic on 2/15/15. | |
| // Copyright (c) 2015 Nektar Labs. All rights reserved. | |
| // | |
| import Foundation |
This file contains hidden or 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
| func httpRequestAccessToken() | |
| { | |
| //Concatenate a String composed of the client and secret id's | |
| let authString = "\(kClientIdSandbox):\(kSecretId)" | |
| let authData = authString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true) | |
| let credentials = "Basic \(authData!.base64EncodedStringWithOptions(nil))" | |
| //Create and set configuration object with necessary Header and value parameters | |
| let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() | |
| configuration.HTTPAdditionalHeaders = ["Accept": "application/json", "Accept-Language": "en_US", "Content-Type": "application/x-www-form-urlencoded", "Authorization": credentials] |
This file contains hidden or 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
| NSDictionary *chargeParams = @{ | |
| @"token": token.tokenId, | |
| @"currency": @"usd", | |
| @"amount": result, // this is in cents (i.e. 1000 = $10) | |
| @"lineItems": self.lineItems, | |
| @"name": self.shippingName, | |
| @"email": self.email, | |
| @"address": self.shippingAddress, | |
| @"cityState": self.cityState, | |
| @"zipcode": self.zipcode, |
This file contains hidden or 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
| Parse.Cloud.define("charge", function(request, response) { | |
| console.log("test"); | |
| Stripe.Charges.create({ | |
| amount: request.params.amount, // in cents | |
| currency: request.params.currency, | |
| card: request.params.token | |
| },{ | |
| success: function(httpResponse) { | |
| response.success("Purchase made!"); | |
| }, |