As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
I tested setting up a project exactly as showed in the ios guide for the data store relationships, see code below. I set up the database with one user, one event and one invitation. I get the following error: 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'. Is it something I have missed here?
/// Invitation.swift
class Invitation : NSObject {
var objectId: String?
var status: NSInteger?
var invitee: KCSUser?
var event: Event?
internal override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"objectId" : KCSEntityKeyId,
"status" : "status",
"invitee" : "invitee",
"event" : "event"
]
}
internal static override func kinveyPropertyToCollectionMapping() -> [NSObject : AnyObject]! {
return [
"invitee" : KCSUserCollectionName,
"event" : "Events"
]
}
}
/// Event.swift
class Event : NSObject {
var entityId: String? //Kinvey entity _id
var name: String?
var date: NSDate?
var location: String?
var metadata: KCSMetadata? //Kinvey metadata, optional
var invitations: NSMutableSet?
internal override func hostToKinveyPropertyMapping() -> [NSObject : AnyObject]! {
return [
"entityId" : KCSEntityKeyId, //the required _id field
"name" : "name",
"date" : "date",
"location" : "location",
"invitations" : "invitations",
"metadata" : KCSEntityKeyMetadata
]
}
internal static override func kinveyPropertyToCollectionMapping() -> [NSObject : AnyObject]! {
return [
"invitations": "Invitations"
]
}
internal static override func kinveyObjectBuilderOptions() -> [NSObject : AnyObject]! {
return [
KCS_REFERENCE_MAP_KEY : [
"invitations" : Invitation.self
]
]
}
}
/// AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
KCSClient.sharedClient().initializeKinveyServiceForAppKey(
"kid_W1rh0mjWXZ",
withAppSecret: "ec71b5ea79cf41d6ab94adf608726e27",
usingOptions: nil
)
let store = KCSLinkedAppdataStore.storeWithOptions([
KCSStoreKeyCollectionName : "Events",
KCSStoreKeyCollectionTemplateClass : Event.self
])
let eventId = "5742372fe6eff86975870547" //change to a real id
store.loadObjectWithID(
eventId,
withCompletionBlock: { (objectsOrNil: [AnyObject]!, errorOrNil: NSError!) -> Void in
if errorOrNil == nil {
let event = objectsOrNil[0] as! Event
let invite = event.invitations!.anyObject() as! Invitation // will be realized Invitation object
print(invite)
}
},
withProgressBlock: nil
)
return true
}
Best Answer
P
Pranav J
said
over 7 years ago
Hey Simon,
It seems like you don’t have an active user - the one who is logged into the app. The app needs an active user.
In short, you will need to login to get the active user context:
KCSUser.loginWithUsername(
“xxxx",
password: “xxxx",
withCompletionBlock: { (user: KCSUser!, errorOrNil: NSError!, result: KCSUserActionResult) -> Void in
if errorOrNil == nil {
//the log-in was successful and the user is now the active user
// DO YOUR LOGIC HERE
}
}
)
Thanks,
Pranav
Kinvey Support
1 Comment
P
Pranav J
said
over 7 years ago
Answer
Hey Simon,
It seems like you don’t have an active user - the one who is logged into the app. The app needs an active user.
In short, you will need to login to get the active user context:
KCSUser.loginWithUsername(
“xxxx",
password: “xxxx",
withCompletionBlock: { (user: KCSUser!, errorOrNil: NSError!, result: KCSUserActionResult) -> Void in
if errorOrNil == nil {
//the log-in was successful and the user is now the active user
// DO YOUR LOGIC HERE
}
}
)
Simon Bengtsson
I tested setting up a project exactly as showed in the ios guide for the data store relationships, see code below. I set up the database with one user, one event and one invitation. I get the following error: 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil'. Is it something I have missed here?
Hey Simon,
It seems like you don’t have an active user - the one who is logged into the app.
The app needs an active user.
Please take a look at the following link:
http://devcenter.kinvey.com/ios/guides/users#ActiveUser
In short, you will need to login to get the active user context:
Thanks,
Pranav
Kinvey Support
Pranav J
Hey Simon,
It seems like you don’t have an active user - the one who is logged into the app.
The app needs an active user.
Please take a look at the following link:
http://devcenter.kinvey.com/ios/guides/users#ActiveUser
In short, you will need to login to get the active user context:
Thanks,
Pranav
Kinvey Support
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics