This is a library to solve all the crashes due to Parse's (arguably) poor handling of nils.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
GRNPFObject
.gitignore
GRNPFObject.podspec
LICENSE
README.md

README.md

GRNPFObject

This library has been created by www.guarana.io

This is a library to solve all the crashes due to Parse's (arguably) poor handling of nils. It wraps PFObject & co. to always check for nil, before passing them over to Parse.

Installation

Cocoapods

pod 'GRNPFObject', '~> 0.0.3'

Click here more information about cocoapods and how to install it

Manual

Drag the folder GRNPFObject into your project.

Usage

PFQuery cannot do a comparison query for type: (null)

Problem

Consider, for example, the following query:

PFQuery *query = [PFComment query];
[query whereKey:@"post" equalTo:post];
[query findInBackground];

If post == nil, the call to findInBackground would crash, due to a NSInvalidArgumentException.

Solution

When subclassing your PFObject, sublass GRNPFObject instead.

@interface PFComment : GRNPFObject <PFSubclassing>

Don't forget to import the headers.

If you don't like subclassing PFObject (I hear you, my friend), then this library will work as long as you use PFSafeQuery:

PFQuery *query = [PFSafeQuery queryWithClassName:@"Comment"];

NSInvalidArgumentException: Can't use nil for keys or values on PFObject. Use NSNull for values.

Problem

You will get this crash when you are trying to insert a nil into one of your PFObject. This can happen, for example, when you are expecting a facebook_id, but you don't get one.

Solution

Same solution as before: subclass GRNPFObject. Your nil will auto-magically be converted into [NSNull null]. This will show up as undefined in your Parse table.