Questions tagged «objective-c»

仅在有关Objective-C功能或取决于语言代码的问题上使用此标记。标签[cocoa]和[cocoa-touch]应该用于询问Apple的框架或类。使用相关标签[ios],[macos],[apple-watch]和[tvos]来解决特定于这些平台的问题。


7
用于将PLIST转换为JSON的命令行工具?
是否有命令行工具可用于将.plist文件转换为JSON? 如果不是,在Mac上使用Objective-C或C创建一个的方法是什么?例如,有用于Objective-C的JSONKit。如何打开一个.plist文件,将其传递给JSONKit,然后将其序列化为JSON?


4
何时在Objective-C中使用responsToSelector
- (void)someMethod { if ( [delegate respondsToSelector:@selector(operationShouldProceed)] ) { if ( [delegate operationShouldProceed] ) { // do something appropriate } } } 该文档说: 仅对于正式协议中的可选方法或非正式协议中的方法,才需要采取预防措施 这是什么意思?如果我使用正式协议,我可以使用[delegate myMethod]?
67 objective-c  ios 



3
NSNotificationCenter的帖子导致“ EXC_BAD_ACCESS”异常
AUIViewController将自身添加到默认中心: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(editFood) name:@"editFood" object:nil]; 然后,UITableView委托NSObject发布NSNotification: [[NSNotificationCenter defaultCenter] postNotificationName:@"editFood" object:self]; 在运行时,它将获得EXC_BAD_ACCESS异常。 在defaultCenter得到释放的地方?当我从UIViewController向UIViewController发布通知时,相同的概念起作用,但这没关系,对吧?


5
如何在IOS13中找到此字体相关的coretext警告的来源?
在更新我的应用程序时,我注意到在IOS13上的Xcode 11.2中运行该应用程序时,我在日志中收到大量警告。 CoreText注意:客户端请求的名称为“ .SFUI-Regular”,它将获得TimesNewRomanPSMT而不是预期的字体。所有系统UI字体访问均应通过适当的API进行,例如CTFontCreateUIFontForLanguage()或+ [UIFont systemFontOfSize:]。 我挖了一下,发现了WWDC的这句话: 正如在许多WWDC会话中提到的那样,不要直接使用点前缀的字体名称。 我本人几乎只使用IB和笔尖为文本字段等设置字体,并且我的代码中均未引用“ SFUI-Regular”,因此我不确定如何找到这些警告的实际原因(我有在日志中大约有20-30行)。 是否有人对我如何找到警告的来源以及如何解决它有任何提示?

1
使用swizzling方法在所有UIViewController实例上一次更改iOS13上的modalPresentationStyle
[问与答] 是否可以UIViewController.modalPresentationStyle在iOS 13上全局更改值,使其表现得像在iOS 12(或更早版本)上一样? 为什么? 在iOS版SDK 13的默认值UIViewController.modalPresentationStyle属性已经从改变UIModalPresentationFullScreen到UIModalPresentationAutomatic是,据我所知,解决了UIModalPresentationPageSheet在iOS设备上,或者至少在iPhone上。 由于我已经工作了几年的项目变得非常庞大,因此在很多地方都提供了视图控制器。新的演示样式并不总是与我们的应用程序设计匹配,有时会导致UI崩溃。这就是为什么我们决定改UIViewController.modalPresentationStyle回UIModalPresentationFullScreen为iOS13 SDK之前的版本。 但是,viewController.modalPresentationStyle = UIModalPresentationFullScreen在调用presentViewController:animated:completion:控制器的每个位置进行调用之前添加似乎太过分了。而且,那时我们还有更严重的事情要处理,这就是为什么暂时或至少在我们更新设计并解决所有UI问题之前,我们决定采用方法混淆方法的原因。 我的答案中给出了有效的解决方案,但是希望您能收到任何反馈,告诉我这种方法可能带来的不利影响或后果。
11 ios  objective-c  swift  ios13 

5
当应用程序在后台运行时,iOS 13.3中未调用didReceiveRemoteNotification
我在敲头。我正在实施推送通知。一切正常(接收到推送,更新了徽章),但是在iOS 13.3下,当应用程序在后台运行时,不会调用application(_:didReceiveRemoteNotification:fetchCompletionHandler :)方法。如果应用程序在前台或使用iOS 12设备,则将调用该方法。我通过以下方式注册推送通知: [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (granted) { dispatch_async(dispatch_get_main_queue(), ^{ [[UIApplication sharedApplication] registerForRemoteNotifications]; }); } }]; 有效负载设置为以下 {"aps": { "badge": 10, "alert": "test", "content-available": 1 }} 我尝试在所有变体中添加“远程通知”和“背景处理”作为应用程序功能(仅“远程通知” /“背景处理”,而没有其中的任何一项功能,同时启用了这两项),而没有进行任何更改。我为UNUserNotificationCenter设置了委托,但是再次失败了。我相应地设置标题: curl -v \ -H 'apns-priority: 4' \ -H 'apns-topic: …

1
-[UIThreadSafeNode canPerformAction:withSender:]:无法识别的选择器已发送到实例
我在我的iOS应用中遇到了崩溃。 Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0x1b9079c30 __exceptionPreprocess 1 libobjc.A.dylib 0x1b8d940c8 objc_exception_throw 2 CoreFoundation 0x1b8f77fc0 -[NSOrderedSet initWithSet:copyItems:] 3 CoreFoundation 0x1b907e3d4 ___forwarding___ 4 CoreFoundation 0x1b9080570 _CF_forwarding_prep_0 5 UIKitCore 0x1bcf33444 -[UIKeyboardImpl deleteForwardAndNotify:] 6 UIKitCore 0x1bcf39154 __57-[UIKeyboardImpl acceptPredictiveInput:executionContext:]_block_invoke 7 UIKitCore 0x1bcf5b0c8 -[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:] 8 UIKitCore 0x1bcf366ec __100-[UIKeyboardImpl addWordTerminator:afterSpace:afterAcceptingCandidate:elapsedTime:executionContext:]_block_invoke 9 UIKitCore 0x1bcf5b0c8 -[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:] …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.