web services (e.g., simple cloud based persistence, or a new social network). • Parse provides SDKs for mobile devs, including a native Objective-C framework for iOS. • Allows rapid development of app-backing web services by obscuring many aspects otherwise required to develop and deploy web-service fueled apps. Overview of Parse
iCloud, you’ll find Parse very simple to introduce into your apps. • Actually simpler to implement a trivial persistence solution with Parse than either...
No servers to configure or maintain, no time spent implementing support for users, queries, or parsing in server or client code. • Until you’re making 1,000,000 API requests a month, VC’s are paying for your EC2 hosting. • Not sandboxed
user reference • Authenticate the user to a web service • Query the web service • Parse response to produce results • Respond to results (eg, update UI or handle error condition) • Authenticate user if required • Query the web service • Respond to results (eg, update UI or handle error condition) Traditional w/ Parse Required Steps for Consuming Web Services
sync and async flavors • save / saveInBackground • getObject / getObjectInBackground • saveEventually (will save when network permits) • Completion handling with delegate callbacks or blocks • Today’s discussion is block-centric
• Values must be JSON-encodable • Strings, numbers, arrays, dictionaries • Consider a PFObject a model object (eg, NSManagedObject or NSObject subclass)
[gameScore setObject:@"Joe" forKey:@"playerName"]; [gameScore setObject:[NSNumber numberWithBool:NO] forKey:@"cheatMode"]; [gameScore save]; •Model Class created lazily •createdAt & updatedAt attributed implicitly •Each object has unique ID •Relationships are defined by associations drawn in code (schema-less)
Hooks for linking Twitter/Facebook accounts • Anonymous/default users • [PFUser currentUser] singleton - (void)myMethod { PFUser *user = [PFUser user]; user.username = @"my name"; user.password = @"my pass"; user.email = @"[email protected]"; // other fields can be set just like with PFObject [user setObject:@"415-555-0101" forKey:@"phone"]; [user signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (!error) { // Hooray! Let them use the app now. } else { NSString *errorString = [[error userInfo] objectForKey:@"error"]; // Show the errorString somewhere and let the user try again. } }]; }
kPFCachePolicyNetworkElseCache • Determine if a given object exists in cache • BOOL existsInCache = [query hasCachedResult] • Count objects matching query without fetching them • Use countObjects instead of findObjects
groups or individuals in app or via web interface • User Interface • PFQueryTableViewController simplifies presenting lists-by-query • E-Mail Verification & Password Resets
Users don’t like to discover that their address books have been uploaded. • If you must upload personal info, hash it first. • Maintain a transparent privacy policy. • Side note: Be careful what you NSLog! • Handle errors gracefully • It’s always exciting to move to the next feature. Resist the urge.