0
我試圖從解析後端下載圖像。它通過創建一個PFQuery,設置Parse類的名稱,可選地設置日期(將在最終版本中的ofc)並查找對象,在UITableView的背景中顯示「今天的圖像」。但是,它給了我一個錯誤。從解析下載圖像
// Create a query and set it up to find todays pic
NSLocale *currentLocale = [NSLocale currentLocale];
PFQuery *todayQuery = [PFUser query];
todayQuery = [PFQuery queryWithClassName:@"Today"];
[todayQuery findObjectsInBackgroundWithBlock:^(NSArray *result, NSError *error) {
// Download the image
NSData *imageData;
for (PFObject *object in result) {imageData = [object objectForKey:@"todaysPic"];}
// Use the image
UIImage *todaysPicture = [UIImage imageWithData:imageData];
UIImage *finalTodaysPicture = [[UIImage alloc] init];
finalTodaysPicture = [self blur:todaysPicture];
self.tableView.backgroundColor = [UIColor colorWithPatternImage:finalTodaysPicture];
}];
// Convert to JPEG with 50% quality
NSData* data = UIImageJPEGRepresentation([UIImage imageNamed:@"star.jpg"], 0.5f);
PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:data];
這裏是我的解析行:
的Xcode告訴我這一點:
2014-10-09 19:05:55.496 iStory[1082:4130995] -[PFFile length]: unrecognized selector sent to instance 0x7fd18bc311f0
和:
(lldb) bt
* thread #1: tid = 0x3f0cf1, 0x000000010c4d6b8a libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x000000010c4d6b8a libobjc.A.dylib`objc_exception_throw
frame #1: 0x000000010c84450d CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 205
frame #2: 0x000000010c79c7fc CoreFoundation`___forwarding___ + 988
frame #3: 0x000000010c79c398 CoreFoundation`__forwarding_prep_0___ + 120
frame #4: 0x000000010d077559 UIKit`_UIImageRefFromData + 57
frame #5: 0x000000010cedc55f UIKit`-[UIImage(UIImagePrivate) _initWithData:preserveScale:cache:] + 110
frame #6: 0x000000010ced89d1 UIKit`+[UIImage imageWithData:] + 50
* frame #7: 0x000000010ab937cf iStory`__37-[HomeViewController viewWillAppear:]_block_invoke(.block_descriptor=0x00007f94495a3c40, result=0x00007f9449552b80, error=0x0000000000000000) + 655 at HomeViewController.m:70
frame #8: 0x000000010abe0ac7 iStory`__49-[BFTask(.block_descriptor=<unavailable>, task=<unavailable>) thenCallBackOnMainThreadAsync:]_block_invoke + 251 at BFTask+Private.m:59
frame #9: 0x000000010abf91a8 iStory`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x00007f94495a50d0) + 30 at BFTask.m:287
frame #10: 0x000000010e651cc6 libdispatch.dylib`_dispatch_call_block_and_release + 12
frame #11: 0x000000010e66f7f4 libdispatch.dylib`_dispatch_client_callout + 8
frame #12: 0x000000010e658991 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 956
frame #13: 0x000000010c7a5569 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #14: 0x000000010c76846b CoreFoundation`__CFRunLoopRun + 2043
frame #15: 0x000000010c767a06 CoreFoundation`CFRunLoopRunSpecific + 470
frame #16: 0x000000010ff409f0 GraphicsServices`GSEventRunModal + 161
frame #17: 0x000000010cea6550 UIKit`UIApplicationMain + 1282
frame #18: 0x000000010ab928a3 iStory`main(argc=1, argv=0x00007fff55077370) + 115 at main.m:14
frame #19: 0x000000010e6a4145 libdyld.dylib`start + 1
(lldb)
非常感謝幫助!
謝謝!
真誠, 埃裏克