草庐IT

Nil-Coalescing

全部标签

iOS:即使单元格可见,cellForItemAtIndexPath 也返回 nil

我有一个CollectionView并且我已经实现了拖放功能。此外,当单元格靠近顶部或底部边缘时,我会以恒定速度滚动集合。当我拖动单元格时,我会根据手势设置它的转换属性,并且我还会在滚动时修改值。我还更改了索引路径布局属性的转换属性。该单元格始终位于屏幕上的手势位置。但是,在某些时候集合决定隐藏单元格,并且cellForItemAtIndexPath返回nil。为什么会发生这种情况,我该如何避免这种情况? 最佳答案 我也有同样的问题。在请求对单元格的引用之前,我通过调用layoutIfNeeded来解决它。self.collecti

ios - iPhone模拟器 : is booted but getenv returned nil for test connection socket path

完整的错误是iPhoneSimulator:SimiPhone5isbootedbutgetenvreturnednilfortestconnectionsocketpath.我在使用snapshot运行测试时得到了这个.因此(我认为)我的测试失败了。我已经尝试重置我的模拟器,但没有任何区别。这是为什么造成的?更新:当为多种语言拍摄快照时会发生这种情况。我尝试为“en-US”制作快照,效果很好。然后我尝试了“es-ES”并且工作得很好。但每当我尝试为两者制作快照时,它都会失败。 最佳答案 这在snapshot中已修复,每次运行后重新

ios - 为通用类型返回 Nil

我有以下代码:classFunction{varptr:()throws->Tinit(block:Func,args:AnyObject...){self.ptr={()throws->Tinletresult:AnyObject?=nilifT.self==Void.self{returnVoid()as!T}returnresult//ErrorHere..Cannotas!castiteither..CannotunsafeBitCastiteither..}}}postfixoperator^{}postfixfunc^(left:Function)throws->T{ret

ios - nil 不是用于搜索实体名称 'GroupMessageInfo' 的合法 NSPersistentStoreCoordinator

错误信息:persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatorisnil??persistentStoreCoordinatori

ios - UILocalNotification 的 UserInfo 始终为 nil

我正在创建简单的UILocalNotification,没有调度,只是从后台使用以下代码:letn=UILocalNotification()n.alertBody="\(nam)\(wat)"n.userInfo=["id":id,"t":type.rawValue]n.soundName=UILocalNotificationDefaultSoundNamen.category="call_chat"app.scheduleLocalNotification(n)我正在打印userInfofuncapplication(_application:UIApplication,didR

ios - TwitterKit 偶尔会为现有用户返回 nil session

当用户打开我的应用时,登录流程如下:使用Twitter.sharedInstance().start(withConsumerKey:consumerKey,consumerSecret:consumerSecret)启动TwitterKit。使用Fabric.with([Crashlytics.self,Twitter.self])启动Fabric。使用Twitter.sharedInstance().sessionStore.session()检查现有session。如果没有现有session,允许他们使用Twitter.sharedInstance().logIn(withMet

objective-c - IOS NSString 属性在引用类中始终为 nil

这是我的@interfacedef;@interfaceThumbnail:UIView{NSMutableString*imageCacheKeyBase;}@property(nonatomic,copy)NSMutableString*imageCacheKeyBase;@end这是我的@实现:@synthesizeimageCacheKeyBase;然后在Thumbnail类中名为initWithAsset的方法中:self.urlString=[[_asset.defaultRepresentation.urlabsoluteString]copy];c=(char*)[ur

iphone - '+entityForName : nil is not a legal NSManagedObjectContext

当我尝试将我的数据从核心数据加载到TableViewController时出现错误。我相信这是由于managedObject没有被正确传递。但我相信我是在对didFinishLaunchingWithOptions下的AppDelegate.m中的代码进行了一些研究之后才这样做的。错误***Terminatingappduetouncaughtexception'NSInvalidArgumentException',reason:'+entityForName:nilisnotalegalNSManagedObjectContextparametersearchingforentit

iOS downloadTaskWithRequest 在 iPhone 的后台 session 中调用时返回 nil,在模拟器中工作

-(NSURLSession*)sharedBackgroundSession{staticNSURLSession*sharedBackgroundSession=nil;staticdispatch_once_tonceToken;dispatch_once(&onceToken,^{NSURLSessionConfiguration*configuration=[NSURLSessionConfigurationbackgroundSessionConfiguration:@"com.example.apple-samplecode.SimpleBackgroundTransfe

ios - Xcode7 合成 setter settableview for null resettable property 不处理 nil

在iOS9中我收到警告这是在UITableViewController上。虽然一切正常,但我只想真正理解这个警告的含义。所以当tableView设置为nil时,setter不会处理。我可以覆盖setter来消除警告,但是有没有更好的方法来解决这个问题?还是我一开始就不应该合成内置属性?-(void)setTableView:(UITableView*)inTableView{if(!inTableView){return;}[supersetTableView:inTableView];} 最佳答案 您有两种选择来实现null_re