草庐IT

about_nil

全部标签

ios - URLForUbiquityContainerIdentifier 总是返回 nil

模拟器是iOS8.1,我用的是Xcode6.1.1。我已经尝试了几个不同来源的解决方案:URLForUbiquityContainerIdentifieralwayreturnnilURLForUbiquityContainerIdentifierreturnsnilevenifconfiguredcorrectlyhttps://devforums.apple.com/thread/229509?似乎没有任何效果。我的设置:权利和能力:代码:dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT

ios - ACAccountStore 请求AccessToAccountsWithType :options:completion: returning nil error and granted as NO

我正在尝试使用ACAccountStore进行登录测试,但效果不是很好。我正在尝试像这样访问该帐户:ACAccountStore*store=[ACAccountStorenew];ACAccountType*accountType=[storeaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];NSDictionary*options=@{ACFacebookAppIdKey:@"12345678987654",ACFacebookPermissionsKey:@[@"email"]};[stor

ios - NSArray indexOfObject 返回 nil

知道为什么我不能获得我确定存在于数组中的对象的索引吗?相反,我得到了nil..(lldb)ponewItem(lldb)poself.items()(lldb)po[self.itemsindexOfObject:newItem]谢谢 最佳答案 -indexOfObject:返回类型为NSUInteger的整数,而不是对象引用。因此,您不应使用po(打印对象)调试器命令,而应使用p。它返回0,而不是nil,这意味着它在数组的第一个位置找到了对象。如果找不到对象,-indexOfObject:将返回NSNotFound。Thelowe

swift - fatal error : unexpectedly found nil while unwrapping an Optional value - using UITableView

我在ViewController中使用UITableView。在viewDidLoad中我有这个:varPlayersUserDefault=NSUserDefaults.standardUserDefaults()if(PlayersUserDefault.arrayForKey("playersKey")!=nil){players=PlayersUserDefault.arrayForKey("playersKey")}这段代码给我错误:functableView(tableView:UITableView,numberOfRowsInSectionsection:Int)->I

ios - init的可选性?(coder :) vs init(coder:). 如果nil怎么办?

NSCoding需要init(coder:),但也有此方法的可选版本init?(coder:)。如果返回nil,具体应该怎么办?这甚至是一个问题吗?假设您正在使用init(coder:)初始化大型对象层次结构,每个对象的子对象本身都使用init?(coder:)进行初始化。如果其中一个对象是nil,应用程序不会崩溃吗?父对象不期望一个nil子对象。“initnil”到底是什么意思?classParent:NSCoding{varchildren:[Child]requiredinit?(coderaDecoder:NSCoder){guardletchildren=aDecoder.d

ios - 为什么 XCode 6 中的示例 iOS 应用程序检查非可选变量的 nil?

在MasterViewController.swift文件中XCode6附带的“Master-Details”示例Swift应用程序中,它们定义了objects,如下所示:varobjects=NSMutableArray()然后在insertNewObject方法中,他们在使用之前检查nil:funcinsertNewObject(sender:AnyObject){ifobjects==nil{objects=NSMutableArray()}objects.insertObject(NSDate.date(),atIndex:0)letindexPath=NSIndexPath(

null - nil 和 Optional<T>.None 在 Swift 中是一回事吗?

我对Swift教程有点困惑。是nil只是Optional.None的便捷快捷方式?是否存在从一个到另一个的隐式转换?一些观察:Optional.None==nilnil文字似乎有一个NilType如果这是一个隐式转换,我可以定义我自己的“接受”nil的类型,或者是Optional在这方面有什么特别之处?我不认为定义自定义可转换为nil的类型是个好主意——我只是想了解类型系统在这种情况下是如何工作的。 最佳答案 Ifyoudon’tprovideaninitialvaluewhenyoudeclareanoptionalvariabl

ios - 在设置 doesRelativeDateFormatting = YES 时,stringFromDate 返回 nil

在NSDateFormatter文档中,Ifadateformatterusesrelativedateformatting,wherepossibleitreplacesthedatecomponentofitsoutputwithaphrase—suchas“today”or“tomorrow”—thatindicatesarelativedate.我正在使用以下代码:NSDateFormatter*formatter=[[NSDateFormatteralloc]init];formatter.dateFormat=[NSDateFormatterdateFormatFromTe

ios - dequeueReusableCellWithIdentifier 返回 nil

我正在使用Storyboard的原型(prototype)UITableViewCell并在cellForRowAtIndexPath中调用dequeueReusableCellWithIdentifier时得到nil。我已经三次检查原型(prototype)tableviewcell的Xcode标识符是“PersonCell”,删除原型(prototype)单元格并再次添加它,注释掉UITableViewController的UISearchDisplyDelegate和UISearchBarDelegate继承,但仍然得到nil。我很难过。有人遇到过这个吗?#import"Peop

ios - swift 语言中的 null/nil

我们如何在swift编程语言中定义以下内容:空无无[NSNullnull]换句话说,这些objectivec术语中的每一个的swift等价物是什么。此外,还想知道非objective-c类型(如结构和枚举)是否存在任何特定用例。提前致谢。 最佳答案 关于等价物:NULL在Swift中没有等价物。nil在Swift中也称为nilNil在Swift中没有等价物[NSNullnull]可以在Swift中作为NSNull()访问注意:这些是我根据阅读和玩耍的猜测。欢迎指正。但Swift中的nil/NULL处理与ObjectiveC有很大不同