Krunal
Krunal

Reputation: 6490

how to call constructor in objective c

i am new to iPhone developer,

i want to call constructor manually, how should i call ?

here is my code snippet,

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {


        CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("ePubTutorial.epub"), NULL, NULL);
        pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
        CFRelease(pdfURL);
        self.pageNumber = 1;
        self.backgroundColor = nil;
        self.opaque = NO;
        self.userInteractionEnabled = NO;
    }
    return self;
}

Thanks In Advance !!

Upvotes: 0

Views: 2484

Answers (2)

Saad
Saad

Reputation: 8947

the method containing init with it's name is constructor in iphone. you will call it as

Object* obj = [[Object alloc] initWithFrame:theFram]; 

Upvotes: 0

Novarg
Novarg

Reputation: 7450

Just use that init method. Example:

[[yourClass alloc]initWithFrame:yourFrame];

And I'd recommend buying some books and reading them, they do help

Upvotes: 3

Related Questions