2016-07-05 1 views
0

(BTW, j'ai lu toutes les questions similaires sur SO, s'il vous plaît ne pas me blâmer, si mon erreur est stupide)Impossible de charger l'image à Firebase (sélecteur non reconnu)

Je suis en train de télécharger l'image , que je reçois de imagePicker et redimensionné puis

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { 
    if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage { 
     process(pickedImage) 
    } 
    dismiss(animated: true, completion: nil) 
} 

func process(_ image:UIImage) { 
    print("start processing") 
    let resized = resize(image, size: 256) 
    photo.image = resized 
    let ref = FIRStorage.storage().reference().child("path/to/file") 
    let data = UIImageJPEGRepresentation(resized, 1.0) 
    let md = ref.put(data!) 
    md.observe(.success, handler: { (snap) in 
     //Something onSuccess 
    }) 
} 

func resize(_ image:UIImage, size w:CGFloat) -> UIImage { 
    let scale = CGFloat(w)/image.size.width 
    let newHeight = image.size.height * scale 
    UIGraphicsBeginImageContext(CGSize(width: w, height: newHeight)) 
    image.draw(in: CGRect(x: 0, y: 0, width: w, height: newHeight)) 
    let newImage = UIGraphicsGetImageFromCurrentImageContext() 
    UIGraphicsEndImageContext() 
    return newImage! 
} 

cette erreur jetant sur ref.put(data!)

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSConcreteURLComponents queryItems]: unrecognized selector sent to instance 0x1b093740' 

trace de la pile complète (je l'espère, c'est ce que vous entendez)

thread #1: tid = 0x87f6, 0x394161f0 libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT 
    frame #0: 0x394161f0 libsystem_kernel.dylib`__pthread_kill + 8 
    frame #1: 0x3947e7b6 libsystem_pthread.dylib`pthread_kill + 58 
    frame #2: 0x393c6ff8 libsystem_c.dylib`abort + 76 
    frame #3: 0x3881598e libc++abi.dylib`abort_message + 74 
    frame #4: 0x3882e6e6 libc++abi.dylib`default_terminate_handler() + 254 
    frame #5: 0x38e61f7c libobjc.A.dylib`_objc_terminate() + 192 
    frame #6: 0x3882c1b2 libc++abi.dylib`std::__terminate(void (*)()) + 78 
    frame #7: 0x3882ba08 libc++abi.dylib`__cxa_throw + 116 
    frame #8: 0x38e61dba libobjc.A.dylib`objc_exception_throw + 250 
    frame #9: 0x2e6ce836 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 202 
    frame #10: 0x2e6cd136 CoreFoundation`___forwarding___ + 706 
    frame #11: 0x2e61c098 CoreFoundation`_CF_forwarding_prep_0 + 24 
    frame #12: 0x0024758a ***APP_NAME***`__46-[FIRStorageMetadata dictionaryRepresentation]_block_invoke + 194 
    frame #13: 0x2e60f3ce CoreFoundation`__53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 90 
    frame #14: 0x2e60f300 CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 232 
    frame #15: 0x00247290 ***APP_NAME***`-[FIRStorageMetadata dictionaryRepresentation] + 532 
    frame #16: 0x00246eac ***APP_NAME***`-[FIRStorageMetadata copyWithZone:] + 64 
    frame #17: 0x38e6bcd8 libobjc.A.dylib`objc_setProperty_nonatomic_copy + 32 
    frame #18: 0x0024d93e ***APP_NAME***`__31-[FIRStorageUploadTask enqueue]_block_invoke116 + 682 
    frame #19: 0x004e5f22 ***APP_NAME***`__71-[GSDK_GTMSessionFetcher invokeOnCallbackQueue:afterUserStopped:block:]_block_invoke + 238 
    frame #20: 0x3934ad52 libdispatch.dylib`_dispatch_call_block_and_release + 10 
    frame #21: 0x3934ad3e libdispatch.dylib`_dispatch_client_callout + 22 
    frame #22: 0x3934d6c2 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 278 
    frame #23: 0x2e695680 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8 
    frame #24: 0x2e693f4c CoreFoundation`__CFRunLoopRun + 1308 
    frame #25: 0x2e5fe768 CoreFoundation`CFRunLoopRunSpecific + 524 
    frame #26: 0x2e5fe54a CoreFoundation`CFRunLoopRunInMode + 106 
    frame #27: 0x3356b6d2 GraphicsServices`GSEventRunModal + 138 
    frame #28: 0x30f5d890 UIKit`UIApplicationMain + 1136 
    * frame #29: 0x000945b8 ***APP_NAME***`main + 172 at AppDelegate.swift:11 
    frame #30: 0x3935fab6 libdyld.dylib`start + 2 
+0

pouvez-vous montrer la trace complète de la pile? – Shubhank

+0

@Shubhank a mis à jour la question –

Répondre

1

Le problème ici est que queryItems n'est pas pris en charge sur iOS 7 (ce que je suppose que vous ciblez). La prochaine version du client prendra en charge iOS 7 en utilisant la propriété query à la place.

Dans le même temps, vous pouvez cibler 8+, et cela fonctionnera, en attendant un correctif pour 7.

+0

Oui, je vise vraiment iOS 7, mais je ne peux pas trouver des queryItems dans mon code. data est Data, et md est FIRStorageUploadTask. Est-ce un bug dans Firebase SDK? –

+0

OK, oubliez-le, maintenant je cible iOS8 et test sur iOS9 –

+0

Oui, c'est un problème dans notre SDK que nous aborderons dans notre prochaine version. –