English 中文(简体)
UIViewConller 不易获得的目的财产
原标题:UIViewController Object s property not accessible

缩略语

在我的应用中:didFinishLaunching WithOptions 我的摘录如下。

UIViewController *viewController1 = [[WSWFirstViewController alloc] initWithNibName:@"WSWFirstViewController" bundle:nil];
UIViewController *viewController2 = [[WSWSecondViewController alloc] initWithNibName:@"WSWSecondViewController" bundle:nil];
self.tabBarController = [[TabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];

self.window.rootViewController = self.tabBarController;

[self.tabBarController showSplash];

[viewController1 displayItems];

What I m trying to do is access the displayItems property of the viewController1 object which is of the type WSWFirstViewController.

In WSWFirstViewController.h I have

@property (retain, nonatomic) NSMutableArray *displayItems;

In WSWFirstViewController.m 我有@syntheize showItems。

I can t seem to figure out why I get a:

财产展览 未找到的物项

直到我注意到我的反对(Controller1)是“IDViewController” * 的编号,但WSWFirstViewController *。 但是,这仍然无助于我。

任何建议都值得赞赏。

最佳回答

You should refer your controllers by their proper type:

 WSWFirstViewController *viewController1 = [[WSWFirstViewController alloc] initWithNibName:@"WSWFirstViewController" bundle:nil];
 WSWSecondViewController *viewController2 = [[WSWSecondViewController alloc] initWithNibName:@"WSWSecondViewController" bundle:nil];

 ....

 [viewController1 displayItems];  // this will now work if you are in the same context
问题回答

你们是否在Suntable Array显示器中申报?





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签