What's the Point of (NSError**)error?

后端 未结 6 1099
小蘑菇
小蘑菇 2020-12-16 20:33

Example: The -save: method of NSManagedObjectContext is declared like this:

- (BOOL)save:(NSError **)error

Since

6条回答
  •  萌比男神i
    2020-12-16 21:11

    If you just passed in a pointer, all the method could do would alter the already existing NSError object that you are pointing to.

    You cannot alter an NSError object.

    NSError is immutable. That's the reason you need the pointer to the NSError variable. You can only create a brand new NSError. Thus you change the pointer to point to your newly created NSError.

提交回复
热议问题