Skip to content

Adding more than one object to PFRelation in PFObject subclass "Operation is invalid after previous operation." #911

Closed
@meoz

Description

@meoz
  • Using LocalDataStore
  • Subclass of PFObject is defined like this:
//PList.h
@interface PList : PFObject<PFSubclassing>
+ (NSString *)parseClassName;

@property (retain) NSString *name;
@property (retain) PFRelation *notes;
@end

//PList.m
@implementation PList
@dynamic name;
@synthesize notes = _notes;
+ (void)load {
    [self registerSubclass];
}
+ (NSString *)parseClassName {
    return @"PList";
}

- (PFRelation *)notes{
    if(_notes == nil) {
        _notes = [self relationForKey:@"notes"];
    }
    return _notes;
}
- (void)setNotes:(PFRelation *)notes{
    _notes = notes;
}
@end

//----------

Used in code like this:
PNote *note = [PNote Object];
note.name = @"mynote";

PList list = ....
 PFRelation *relation = [list notes];
[relation addObject:note];
 [list saveInBackground];

Adding one 'note'-object goes without problems, I can see the object appearing on the dashboard. But when adding a second 'note' object an exception is thrown: [NSException raise:NSInternalInconsistencyException format:@"Operation is invalid after previous operation."];

-> object in relation is not added

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions