compiler error related to 'save' method of NSUserDefaultsController

  • The below code snippet causes 3 warnings which make no sense to me.

    /Users/chris/Development/CHmessenger/CHmessenger.mm:627: warning:
    multiple methods named '-save:' found

    /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
    AppKit.framework/Headers/NSUserDefaultsController.h:46: warning:
    using '-(void)save:(id)sender'

    /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/
    CoreData.framework/Headers/NSManagedObjectContext.h:128: warning:
    also found '-(BOOL)save:(NSError **)error'

    Has anyone ever seen this before? I am running Tiger 10.4.10 & XCode
    2.4.1. My usage of the method exactly mimics the class definition so
    I am very confused.

    Chris

    - (void)applicationWillTerminate:(NSNotification *)aNotification
    {
    [[NSFileManager defaultManager] removeFileAtPath:tempApplication
    handler:self];

    if ([[NSUserDefaultsController sharedUserDefaultsController]
    hasUnappliedChanges])
    {
      [[NSUserDefaultsController sharedUserDefaultsController] save:self];
    }
    }
  • On Nov 11, 2007, at 2:04 PM, Chris Heimark wrote:

    > /Users/chris/Development/CHmessenger/CHmessenger.mm:627: warning:
    > multiple methods named '-save:' found
    >
    <http://www.google.com/search?client=safari&rls=en-us&q=warning:+mul
    tiple+methods+named&ie=UTF-8&oe=UTF-8
    >

    mmalc
  • OK. Makes complete sense that Obj-C doesn't know because that
    particular class method returns an ID rather than a specific class
    instance pointer. The following solves the problem and satisfies the
    compiler:

    NSUserDefaultsController *sudc = [NSUserDefaultsController
    sharedUserDefaultsController];
    [sudc save:self];

    That still doesn't tell me why Apple chose to have an ID returned
    rather than the standard convention. Is this just an aberration or is
    there a specific reason why in this case they chose to return an ID?

    Chris

    On Nov 11, 2007, at 5:16 PM, mmalc crawford wrote:

    >
    > On Nov 11, 2007, at 2:04 PM, Chris Heimark wrote:
    >
    >> /Users/chris/Development/CHmessenger/CHmessenger.mm:627: warning:
    >> multiple methods named '-save:' found
    >>
    > <http://www.google.com/search?client=safari&rls=en-us&q=warning:
    > +multiple+methods+named&ie=UTF-8&oe=UTF-8>
    >
    > mmalc
    >
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today