保存和加载数据在今天扩展(iOS 8)

是否有可能使用NSUserDefaults在Today Extension上保存和加载数据? closures通知中心后,小部件的行为就像一个终止的应用程序,所以任何数据结果都会丢失。 我怎么能解决这个问题? 这是我的代码: NSUserDefaults *defaults; – (void)viewDidLoad { [super viewDidLoad]; defaults = [NSUserDefaults standardUserDefaults]; NSArray *loadStrings = [defaults stringArrayForKey:@"savedStrings"]; if ([loadStrings objectAtIndex:0] != nil) { [display setText:[NSString stringWithFormat:@"%@", [loadStrings objectAtIndex:0]]]; } if ([loadStrings objectAtIndex:1] != nil) { calculatorMemory = [NSString stringWithFormat:@"%@", [loadStrings objectAtIndex:1]].doubleValue; } } – (IBAction)saveData:(id)sender { NSString *displayString; NSString *memoryString; NSArray […]

NSArray.array / .new / @ / alloc-init之间的区别

似乎有不同的方法实例化NSArrays(NSDictionary和其他一些)。 我知道: [NSArray array] [NSArray new] @[] [[NSArray alloc] init] 出于可读性的原因,我通常坚持使用[NSArray array] ,但所有这些之间的区别是什么,它们是否都一样?

由于未捕获exception“NSInternalInconsistencyException”而终止应用程序,原因:'无法在软件包中加载NIB

尝试在我的设备上运行我的应用程序,运行时出现以下SIGART错误: 由于未捕获的exception“NSInternalInconsistencyException”而终止应用程序,原因:'无法在捆绑包中加载NIB:'名为'ViewController'的NSBundle(已装载)'' 我有非常有限的iOS经验和知识,但我认为它可能与以下代码片段在我的ViewController.m -(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { log = [[NSMutableString alloc] init]; } return self; } 有谁知道这是为什么发生?

我可以在iPad上使用哪种UIKeyboardType

我在我的iPad应用程序中有一个textField对象。 我想给用户一个方便的键盘input数字。 在我的代码中我添加了: UITextField *textField = [[UITextField alloc] initWithFrame:frame]; textField.keyboardType = UIKeyboardTypeDecimalPad; 根据文档这是一个有效的键盘types,但是当我编辑文本字段正常的ASCII键盘出现。 但是,当我将其更改为: textField.keyboardType = UIKeyboardTypePhonePad; 键盘看起来像这样: 理想情况下,我想要一个只有数字和小数点的键盘,但这不可能在iPad上? 有没有人有iPhone和iPad上的哪些键盘工作的权威列表? 苹果目前还不清楚这一点。 我也看到了类似的问题 ,但是没有一个答案真正解决了我的观点。 谢谢!

提交iOS应用程序时是否可以排除3.5英寸屏幕设备?

当提交iOS应用程序到iTunes连接时,是否可以排除 3.5“设备?我不想支持这个屏幕尺寸,只有4”及以上。

从使用iOS 6 SDK构build的应用程序中排除AirDrop和添加到阅读列表

我有一个UIActivityViewController在我的iOS 6应用程序,我推更新,但我还没有编译与iOS 7 SDK。 有没有办法禁用iOS7中的UIActivityViewController添加到阅读列表和AirDrop,而无需使用iOS 7 SDK进行重新编译?

不能去工作cocoa豆和优胜美地

我已经试过这个步骤: 打开Xcode 6打开首选项 点击地点标签 将命令行工具版本更改为Xcode 6.0 卸载cocoapods 一个。 $ sudo gem卸载cocoapods安装xcodeproj 一个。 $ sudo gem install xcodeproj安装cocoapods 一个。 $ sudo gem安装cocoapods 运行pod –version来validation它是否有效 但是当我做pod安装或者pod –version的时候,我还是得到了这个: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file — xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:6:in `rescue in <top (required)>' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:3:in `<top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj.rb:30:in […]

申请被拒绝,因为没有遵循iOS数据存储指南

我们正在将数据存储到应用程序的Document目录中,并且我们拒绝了应用程序。 我们已经尝试过使用“不备份”属性来存储当前版本的数据和下面的代码。 – (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL{ const char* filePath = [[URL path] fileSystemRepresentation]; const char* attrName = "com.apple.MobileBackup"; u_int8_t attrValue = 1; int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0); return result == 0; } 我们根据iOS数据存储指南使用它。 在早期版本中,我们也尝试将数据存储在私人目录中。 但是,我们没能得到申请的批准。 你能不能给我们更多的描述,为什么我们不能得到批准的申请? 或者,我们还需要对数据存储进行其他更改吗? 所以,我们可以得到批准,我们已经在iTunes上的新版本的应用程序。

Maskstobounds vs clipstobounds

就我而言, clipstobounds和maskstobounds都做同样的工作。 我找不到他们之间的任何区别。 有人很好解释两者是如何不同的。

NSURLErrorDomain错误-1012

我需要parsing密码保护的URL的XML文件我试着下面 NSURLCredential *credential = [NSURLCredential credentialWithUser:@"admin" password:@"123456" persistence:NSURLCredentialPersistenceForSession]; NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"xyz.com" port:80 protocol:@"http" realm:nil authenticationMethod:NSURLAuthenticationMethodDefault]; [[NSURLCredentialStorage sharedCredentialStorage] setCredential:credential forProtectionSpace:protectionSpace]; url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; [request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"]; connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; NSURLResponse *response; NSError *error; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse: &response error: &error]; […]