I’m trying to add a value I get back from an API call to an object in Objective-C. I get an error in Xcode saying “Expression is not assignable” and don’t understand why. In my carObj I have an object called warrantyPlan with a nil value and I’m trying to set the value for warrantyPlan. What am I doing wrong in this method?
NSArray *carUUIDs = [carData valueForKeyPath:@"uuid"];
NSString *ownerUUID = ownerRecord[@"uuid"];
if (ownerID) {
NSManagedObjectContext *context = [DataCenter viewContext];
NSObject *carObj = [context objectsForEntityName:[CarObject entityName] matchingUUIDs:carUUIDs];
for (id carID in carUUIDs){
[WarrantyPlansService getWarrantyPlansForCarWithCarID:carID ownerID:ownerUUID completion:^(NSArray* response, NSError* error){
//attach the response to the carData
NSLog(@"%@", [carObj valueForKeyPath:@"warrantyPlans"]);
[carObj valueForKeyPath:@"warrantyPlans"] = response;
}];
}