开发者

How to intilized controller with initWithmyData and with initWithStyle:UITableViewStyleGrouped?

I have one controller inheriting UITableViewController, and call the object as below

        editAlarm *ob = [[editAlarm alloc] initWithStyle:UITableViewStyleGrouped];
        UINavigation开发者_JAVA技巧Controller *nc = [[UINavigationController alloc] initWithRootViewController:ob];
        ob.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController:nc animated:YES];
        [ob release];
        ob =  nil;
        [nc release];
        nc = nil;

now the table will initialized with groupstyle, but I want an object with it my data as normally I do in many of my projects

-(id)initwithData:(myFaceData *)dat{
id i=[super init];
self.data=dat; where data is object having some variables in it
return i;
 }


    myFaceData *data=[myArray objectAtIndex:tag];
    editAlarm *ob = [[editAlarm alloc] initwithData:data];
[self.navigationController pushViewController:details animated:NO];

Now How can I do two init at same time, what is solution so that my object will pass along with init of new class(Controller)

If someone is not clear about question, then feel free to ask in comments

Thanks in Advance :-)


What you could do is make your data variable a Property (and synthesise it) so you can set it right after you init it in the class you are initialising it.

Alternatively you could create your own init method as follows:

- (id)initWithStyle:(UITableViewStyle)style andData:(myFaceData *)dat {
    if ((self = [super initWithStyle:style])) {
        self.dat = dat;
    }

    return self;
}

And to call your initialiser you could do this in the calling class (where theData is the data to be passed across):

editAlarm *ob = [editAlarm alloc] initWithStyle:UITableViewStyleGrouped andData:theData];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜