Objective c 带iAction的xcode
我正在尝试用xcode制作一个应用程序。我制作了一个名为Objective c 带iAction的xcode,objective-c,xcode,Objective C,Xcode,我正在尝试用xcode制作一个应用程序。我制作了一个名为myApp.m和.h 在my.m中,我有这些代码行 - (void)loadApp AlarmItem *item1 = [[[AlarmItem alloc] initWithTitle:@"TEST2"] autorelease]; NSMutableArray *items = [NSMutableArray arrayWithObjects:item1, nil]; RootViewController *rootControll
myApp.m
和.h
在my.m
中,我有这些代码行
- (void)loadApp
AlarmItem *item1 = [[[AlarmItem alloc] initWithTitle:@"TEST2"] autorelease];
NSMutableArray *items = [NSMutableArray arrayWithObjects:item1, nil];
RootViewController *rootController = (RootViewController *) [navigationController.viewControllers objectAtIndex:0];
rootController.items = items;
在我的RootViewController中,我有一个这样的方法:
- (IBAction)RefreshMyApp:(id)sender {
MyApp *myApp2 = [[[MyAppalloc] init] autorelease];
[myApp2 loadData];
}
我试图做的是从myApp类调用方法并显示在tableView中,但我总是得到一个空单元格
非常感谢您的帮助。这是为了让您获得UIApplication singleton吗?(我猜MyAppalloc是一个拼写错误,应该是MyAppalloc) 如果是这样,那么您应该这样做:
MyApp *myApp2 = (MyApp*)[UIApplication sharedApplication];
如果不是这样,您需要更清楚地说明MyApp是什么(您的应用程序代理?我想,您的应用程序运行在singleton实例中,如果这是某种NSView或您想要刷新的特定控件,您可以调用其特定的刷新方法,如,
[NSTableView重新加载]
[NSTextField setString]
等等 myApp只是一个void方法,我可以将其称为load。我需要的是从该方法重新加载数据,以便它可以显示在我的单元格中。您编写此代码:myApp*myApp2=[[myApp alloc]init]autorelease];MyApp子类是什么类?很抱歉,MyApp是loadApp而不是myApptrue,NS应该替换为UI
MyApp *myApp2 = (MyApp*)[UIApplication sharedApplication];