English 中文(简体)
iphone 。 表1 主计长
原标题:iphone . getter of a tableViewController

我有一封信件。

我将财产制成。

myTVC *myTable;

以及

@property (nonatomic, retain) myTVC *myTable;

then, on .m I have synthesized it 以及 created a getter

@synthesize myTable = _myTable;

以及

- (myTVC *) myTable {

    if (_myTable == nil) { 
        _myTable = [[myTVC alloc] init];
    }
    return _myTable;
}

此时此刻,我只能这样做。

[self presentModalViewController:myTable animated:YES];
[myTable release];

as far as I thought, myTable s getter would run at this point 以及 allocate the tableViewController, but it is not running 以及 the app crashes telling me that I am trying to present a nil tableViewController...

我失踪了什么? 感谢。

最佳回答

页: 1 如果您有<条码>,可打<>。 不是储存的,因为你正在这样做:@synthesize myTable=_myTable;,其中将创设一个iVar 电话_myTable

So you are doing 2 wrongs things in here.
To correct your code do the following :
remove this line : myTVC *myTable;
and do [self presentModalViewController:self.myTable animated:YES];

第3条也与你的法典相左。

[self presentModalViewController:myTable animated:YES];
[myTable release];  // <---- this line, remove it to

我不敢肯定,既然你正在把<条码>控制器<>/条码>储存在“property”中,为什么会存在这一条线。

and a 4th By the way
The default initializer for a UIViewController is the following

- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle

页: 1 如果你没有东西可以去。

问题回答

In

[self presentModalViewController:myTable animated:YES];
[myTable release];

You re not actually calling the myTable method. Do

self.myTable = [self myTable]

首先。 虽然我看不出为什么你们需要一种可观的方法,而不是仅仅做一刀切的事情。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签