Tag: 用户信息

Swift NSTimer将用户信息检索为CGPoint

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { let touch = touches.anyObject() as UITouch let touchLocation = touch.locationInNode(self) timer = NSTimer.scheduledTimerWithTimeInterval(0.5, target: self, selector: "shoot", userInfo: touchLocation, repeats: true) // error 1 } func shoot() { var touchLocation: CGPoint = timer.userInfo // error 2 println("running") } 我正在尝试创build一个计时器,该计时器将周期性地运行,将触摸点(CGPoint)作为userInfo传递给NSTimer,然后在shoot()函数中访问它。 但是,现在我得到一个错误,说 1)调用中的额外参数select器 2)不能转换expression式typesAnyObject? 到CGPoint 现在我似乎无法将userInfo传递给另一个函数,然后检索它。

CoreData上的UserInfo字典

苹果核心数据文档的这一部分是什么意思? 用户信息字典 托pipe对象模型中的许多元素(实体,属性和关系)都具有关联的用户信息字典。 您可以将所需的任何信息放入用户信息字典中作为键值对。 放入用户信息字典的常用信息包括实体的版本详细信息以及谓词用于提取属性的值。 我明白,默认情况下,实体具有该字典,但我无法find在coredata实体或属性上finduserInfo。

Swift读取远程通知的userInfo

我实现了一个函数来打开AlertView,当我收到这样的远程通知: func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]){ var notifiAlert = UIAlertView() var NotificationMessage : AnyObject? = userInfo["alert"] notifiAlert.title = "TITLE" notifiAlert.message = NotificationMessage as? String notifiAlert.addButtonWithTitle("OK") notifiAlert.show() } 但NotificationMessage总是零。 我的JSON有效载荷如下所示: {"aps":{"alert":"Testmessage","badge":"1"}} 我正在使用Xcode 6,Swift和我正在开发的iOS8。 我现在搜查了几个小时,但没有find任何有用的信息。 通知完美地工作..如果我点击它,alertview打开。 我的问题是,我无法从userInfo获取数据。