Tag: parse.com

findObjectsInBackgroundWithBlock:从Parse获取数据,但数据只存在于块内

我做了以下testing类来尝试从Parse中检索数据: -(void)retrieveDataFromParse { PFQuery *query = [PFQuery queryWithClassName:@"TestObject"]; [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if(!error){ for (PFObject *object in objects){ NSString *nameFromObject = [NSString stringWithFormat:@"%@", [object objectForKey:@"Name"]]; NSString *dateFromObject = [NSString stringWithFormat:@"%@", [object createdAt]]; NSString *scoreFromObject = [NSString stringWithFormat:@"%@", [object objectForKey:@"Score"]]; [self addNewScore:scoreFromObject andDate:dateFromObject forUserName:nameFromObject]; NSLog(@"The dictionary is %@", self.scoreDictionary); //<– here it works printing […]

代码更新后,启用iOS 8的设备不会收到PUSH通知

我最近升级了我的一个testingiPhone到iOS 8,然后升级了PUSH注册码如下(使用xCode 6) -(BOOL)hasNotificationsEnabled { NSString *iOSversion = [[UIDevice currentDevice] systemVersion]; NSString *prefix = [[iOSversion componentsSeparatedByString:@"."] firstObject]; float versionVal = [prefix floatValue]; if (versionVal >= 8) { NSLog(@"%@", [[UIApplication sharedApplication] currentUserNotificationSettings]); //The output of this log shows that the app is registered for PUSH so should receive them if ([[UIApplication sharedApplication] currentUserNotificationSettings].types != UIUserNotificationTypeNone) { […]

只有在asynchronous函数完成执行后才能运行代码

我对Swift和Xcode一般都比较陌生,在找出这个问题时遇到了很多困难。 我正在开发一个利用Parse.com后端服务器的应用程序。 为了不阻塞主线程,每当应用程序从服务器下载任何东西时,它都是在asynchronous线程上asynchronous完成的。 然而,其余的代码继续在主线程上执行,并且它应该从服务器获得的数据还没有下载时崩溃。 我想知道如何在asynchronous函数完成后调用函数来运行,而这必须在单独的文件中完成。 我读封闭可能会有所帮助,但我发现那里的语法非常困难,一个解释将不胜感激。 但是,任何方式都会非常有帮助。 谢谢