0

I'm trying to overwrite the initWithFileURL of an UIDocument as I need to call some custom methods once an UIDocument is initialised.

I thought this may be a good idea:

-(id)initWithFileURL:(NSURL *)url {
        self = [super initWithFileURL:url];
        // do some custom stuff
        return self;
}

Is there anything else I need to do if I overwrite this? I have the feeling that I need to check for NIL or something. Where do you usually look if you need to overwrite a method with something custom? I was only able (via jump to definition when right clicking UIDocument) to see this:

    #pragma mark *** Initialization ***

// The designated initializer. Passing an empty URL will cause this method to throw an NSInvalidArgumentException.
- (id)initWithFileURL:(NSURL *)url;
n.evermind
  • 11,944
  • 19
  • 78
  • 122

1 Answers1

1

You should probably be doing this.

-(id)initWithFileURL:(NSURL *)url {
    self = [super initWithFileURL:url];

    if(self) {

      // Your custom stuff here

   }

    return self;
}
skram
  • 5,314
  • 1
  • 22
  • 26