子类化UIDocument的initWithFileURL [英] subclassing initWithFileURL of an UIDocument

查看:105
本文介绍了子类化UIDocument的initWithFileURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖UIDocument的initWithFileURL,因为一旦初始化UIDocument,我需要调用一些自定义方法.

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;
}

如果我覆盖了此内容,还有其他需要做的事情吗?我感觉我需要检查NIL或其他内容.如果需要使用自定义内容覆盖方法,通常会在哪里查看?我只能(通过在右键单击UIDocument时跳转到定义)来查看此内容:

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;

推荐答案

您可能应该这样做.

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

    if(self) {

      // Your custom stuff here

   }

    return self;
}

这篇关于子类化UIDocument的initWithFileURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆