导入AppDelegate

通常我在我的AppDelegate中初始化我的模型类variables,以便它们可以被不同的ViewController使用,而不需要通过类文件传递它们的实例。 但是,每次我把AppDelegate导入到一个.m文件来访问这些variables的数据时,我觉得我正在做一些错误。 这是访问这些variables的正确方法,还是应该做一些不同的事情? 编辑:我的问题不是如何访问variables。 我目前使用这行代码来得到我的appDelegate实例: id appDelegate = [[UIApplication sharedApplication] delegate]; 从概念上讲,我想知道这是否是与应用程序的模型类交互的可接受的方式。 在我看来,应用程序的AppDelegate总体上pipe理着应用程序。 所以将这个类导入到应用程序的类链中的其他类似乎是违反直觉的。

如何删除正在等待上传的应用程序?

根据苹果文档 ,我们可以删除处于等待上传状态的应用程序。 但是,怎么样? 我search删除button,不能得到的。 团队代理如何从我的iTunes连接视图中删除它? 我找不到应用程序详细信息页面中的删除button。

可以在后台线程上创build一个UIView吗?

我知道UIView不是线程安全的,所以我不能添加一个后台线程的视图,解决这个问题是可以在后台线程上创build一个UIView然后将其添加到主线程? 注意:在主线程中不这样做的原因是因为我的实际代码复杂得多,因此需要一段时间才能创build所有视图并填充值。 当我这样做时,我不希望UI变得不响应,所以即时通讯尝试解决这个问题。 例如.. -(void)addLabel//called on background thread { UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0,0,40,100)]; [label setText:@"example"] [self.view performSelector:@selector(addSubview:) onThread:[NSThread mainThread] withObject:example waitUntilDone:YES]; } 提前致谢。

以编程方式突出显示UIBarButtonItem

点击“logging”BarButtonItem后,我想保持它以编程方式突出显示,直到录制结束。 iOS的突出显示graphics非常好,因此我想保留或设置该状态。 到目前为止,我发现“setSelected”和“setHighlighted”,但这些不能在UIBarButtonItem上工作。 有关如何解决这个问题的任何build议? 先谢谢你,Koen。

使用segues将UIViewControllerembedded到NavigationController中

我有一个viewController是通常 (最经常)通过使用push segue访问。 这个viewController需要被embedded到一个UINavigationController中。 所以通常情况下,这是没有问题的。 push seguepipe理viewController,因此viewController拥有它的UINavigationController。 我的问题是,在less数情况下,我想使用模态segue呈现相同的确切的viewController。 当我这样做的时候,viewController没有embedded到navigationController中。 有没有办法使用segues来做到这一点? 我知道这可以通过创build一个UINavigationController,将rootView设置为viewController,然后以模态方式呈现,完全在没有segues的代码中完成。 这可以使用这样的代码来完成: MyViewController *viewController = [[MyViewController alloc] init]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController]; [self presentModalViewController:navController animated:YES]; 但是,我怎样才能做到这一点,但使用Segues? 更新 为了进一步的清晰,这里有一些代码来补充我在prepareForSegue方法中如何使用接受的答案。 当使用模态塞格 – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue destinationViewController] isEqualToString:@"Modal to MyVC"]) { UINavigationController *nav = [segue destinationViewController]; MyViewController *vc = [nav topViewController]; //setup vc […]

推送通知在排除之前需要多长时间才能排队?

我一直在尝试为客户端的苹果推送通知发现一些数据,而我一直无法find答案的是推送通知在离线设备队列中将被移除多长时间。 例如,可能会有很长的时间,例如2-3个月,其中设备可能处于非活动状态并断电。 我只是想知道多久,我可以期待一个通知stream连忘返,等待被传递到一个离线设备,才会被自动删除(这正是我所知道的是什么发生)。

iOS 8 NSInternalInconsistencyException

我收到以下的崩溃报告。 它们只发生在使用iOS 8的设备上。请注意以下消息: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'this request has been neutered – you can't call -sendResponse: twice nor after encoding it' 崩溃报告: Date/Time: 2014-08-31T01:39:15Z OS Version: iPhone OS 8.0 (12A4345d) Report Version: 104 Exception Type: SIGABRT Exception Codes: #0 at 0x1964cb270 Crashed Thread: 0 Application Specific Information: *** Terminating app […]

什么时候NSCachesDirectory文件被删除?

在什么情况下,iOS NSCachesDirectory中的文件被删除? 显然,删除并重新安装一个应用程序。 应用程序升级怎么样? 低磁盘空间条件呢? 还要别的吗?

UIImagecaching图像?

UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"xx.jpg"] UIImage *img = [UIImage imageNamed:@"xx.jpg"] 在第二种types的图像会被caching? 而在第一种types的图像不会被caching?

在主线程上运行NSURLSession完成处理程序

我正在使用NSURLSession来获取值来填充一个TableView。 我正在更新完成处理程序中的TableView,但使用[[NSThread currentThread] isMainThread]已经告诉我,完成处理程序没有在主线程中运行。 由于我只应该从主线程更新UI,我知道这是不正确的。 有没有办法从完成处理程序在主线程上触发一个动作? 或者是使用NSURLSession错误的方式去做这件事? NSURLSession *session = [NSURLSession sharedSession]; [[session dataTaskWithURL:[NSURL URLWithString:@"http://myurl"] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSError *jsonError = nil; NSArray* jsonUsers = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; if (jsonError) { NSLog(@"error is %@", [jsonError localizedDescription]); // Handle Error and return return; } self.userArray = jsonUsers; [self.userTableView reloadData]; if ([[NSThread […]