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
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| let APP_ID = "YOUR-APPLICATION-ID" | |
| let SECRET_KEY = "YOUR-APPLICATION-IOS-SECRET-KEY" | |
| let VERSION_NUM = "v1" | |
| var backendless = Backendless.sharedInstance() | |
| var window: UIWindow? | |
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
| #import "UICollectionView+CellRetrieval.h" | |
| @implementation UICollectionView (CellRetrieval) | |
| -(NSArray *) allCells { | |
| NSMutableArray *cells = [[NSMutableArray alloc] init]; | |
| for (NSInteger j = 0; j < [self numberOfSections]; ++j) | |
| { | |
| for (NSInteger i = 0; i < [self numberOfItemsInSection:j]; ++i) | |
| { |
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.beforeSave("Entry", function(request, response) { | |
| var entry = request.object; | |
| var contest = request.object.get("contest"); | |
| var fetchedUser, fetchedContest; | |
| var errorMessage; | |
| entry.get("user").fetch().then(function(result) { | |
| fetchedUser = result; | |
| return contest.fetch(); |
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
| extension String { | |
| func isValidString() -> Bool { | |
| var charSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_") | |
| charSet = charSet.invertedSet | |
| let range = (self as NSString).rangeOfCharacterFromSet(charSet) | |
| if range.location != NSNotFound { |
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
| // In this example, we will create a class method for our PFUser subclass | |
| // The method will register a new user, but throw certain error types for us to exhaustively handle | |
| // First, we define our errors as an enum that conforms to ErrorType | |
| // Here we anticipate common error cases | |
| enum SignUpError: ErrorType { | |
| case EmptyFields | |
| case TooLong | |
| case TooShort | |
| } |
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 shouldShareToTwitter == true { | |
| if didSaveToTwitter == false { | |
| //In ReviewInfoViewController, we have started a session with logInWithCompletion() | |
| let store = Twitter.sharedInstance().sessionStore | |
| if let userid = store.session()?.userID { | |
| let client = TWTRAPIClient(userID: userid) //we have this from logInWithCompletion() in the previousVC |
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
| #import "VZClassHelper.h" | |
| #import <objc/runtime.h> | |
| @implementation VZClassHelper | |
| +(NSMutableArray *)allPropertiesFromObject:(NSObject *)object ofType:(Class)class | |
| { | |
| NSMutableArray *array = [NSMutableArray new]; | |
| unsigned int count=0; | |
| objc_property_t *props = class_copyPropertyList([object class],&count); |
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)constrainSubview:(UIView *)subview toSuperview:(UIView *)superview { | |
| subview.translatesAutoresizingMaskIntoConstraints = NO; | |
| // initialize | |
| NSLayoutConstraint *width =[NSLayoutConstraint | |
| constraintWithItem:subview | |
| attribute:NSLayoutAttributeWidth | |
| relatedBy:0 | |
| toItem:superview | |
| attribute:NSLayoutAttributeWidth |
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
| @implementation ContactsManager | |
| +(void)requestContactsAccess:(void (^)(BOOL success, ABAddressBookRef addressBook, CFErrorRef error))completionHandler | |
| { | |
| CFErrorRef error = NULL; | |
| ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &error); | |
| ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { | |
| if (!granted) | |
| { |
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
| -(instancetype)initWithName:(NSString *)name andGeoPoint:(PFGeoPoint *)geoPoint { | |
| AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; | |
| self = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([CDRegion class]) inManagedObjectContext:appDelegate.managedObjectContext]; | |
| self.name = name; | |
| self.longitude = [NSNumber numberWithDouble:geoPoint.longitude]; | |
| self.latitude = [NSNumber numberWithDouble: geoPoint.latitude]; | |
| return self; | |
| } |