So I am trying to update to the newest KinveyKit because of some user creation issues on the old sdk. While updating I started getting some crashes on some function calls that before where not have issues. So far there are two errors, which keep in mind work fine on the old sdk.
The first error is CRASH: objectId is `nil'. I am not sure what this is I thought it was a functino I am calling but after looking at hte stack trace it is being called on a Data store that I did not create. I have no idea what might be the cause of this issue. Stack trace is below:
2014-02-26 11:53:53.958 Soulodex[3187:6007] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'objectId is `nil`.'
terminating with uncaught exception of type NSExceptionlibc++abi.dylib:
terminating with uncaught exception of type NSException
This next paragraph is what I was thinking it was but after further looking and testing I am thinking I am wrong. I will leave this in here though for reference.
So I am guessing this is from the loadObjectWithID function that I am calling. Right now I have an array of object id's that I am passing this function and it goes and gets all the objects with those ids. Before it was working fine and getting all the objects correctly. Now though it is saying objetid is nil, and I am not sure if this partisans to the field objectId on the object I am getting out is nil or if it is talking about the array that I am passing it has nil values in it?? My guess is the former and this is why: I have a check to see if the array is nil so that is not it, but also I am not aware of any nil values in the array I am passing it. The code I was thinking is messing up is below but I am just not sure:
The second error I am getting is CRASH: Can't do regex matching on object. The context is I am using a regex to search on an array of strings. So I am creating a query that is geocoding and searching on a array of strings. This was the way it worked on the old SDK I am not sure what has changed and how I need to change it to get the same result on the new SDK. Code is below:
libc++abi.dylib: terminating with uncaught exception of type NSException
Also the last thing as a passing comment: The create user function for older SDK's is broken. I am not sure if this was intentional but figured I would let you all know. When you create a user it creates the user fine but it does not log in the user.
And at first I thought it was that as well but i added in some tests to check for nil values, and nothing was nil. But then at closer look at the stack trace you can see that it called loadObjectWithID 3 times before failing so not sure what to make of it. Could it be a weak pointer thing?? I was thinking it should not be because I make sure I have strong pointers to those objects. Also that would be weird that it would stop working when I update to the newest kinveykit. If you think it will help I can get the exact version of the KinveyKit I am using in this.
Thanks for any Help!
over 8 years ago
What do you mean by a "weak pointer thing"? As you can see from the stack trace that value of "objectId" is passed through to a NSOperation and evaluated sometime later on a different thread, so if there is no reference back to the objectIds this will be nil. I'm also going to do the parameter assert earlier in this case in the next version of the lib just to check that it's not nil coming in to the top call.
over 8 years ago
Haha sorry should have been more specific.
So what I mean by the weak pointer thing is this: if there is not a strong pointer to the object when it is passed to the other functions on another thread/in another class and the original class does not need it anymore it has a chance of being de-allocated. I have had this happen with arrays and/or objects being passed between screens. SO I tend to use strong pointers when ever I can now though. But this seems like one of those issues. Because like I said when I passed in the array it was not nil. The array had object id's in it.
The error is 'objectId is nil.' which suggests it is not my array but a field on a object is nil which makes no since because kinvey sdk handles all that. The name of my array is "objectIds" not "objectId". Now in all of my objects the "_id" field is called "objectId" that is why I am seeing it this way. If this was the case then it would suggest we have an object in the database without a "_id" field. Am I way off base here or are you seeing the discrepancy as well?
over 8 years ago
The array is probably not nil at the time `queryWithQuery` is called, but since that value is not used until later inside a nsoperation on a background queue, it is being cleaned up in between. I'd look at where the array is first generated and the conditions under which that value is removed.
over 8 years ago
Ya I will look into it some more. It is just weird that the same code is working before the update. I will post back just in case anyone else has this issue.