2017-09-21 11 views
0

내가 NSObject의 사용자 정의 클래스의 배열을 채우기 위해 노력하고 있지만, 오전를 설정할 때 인식 할 수없는 선택은 내가 데이터를 삽입 할 때 오류가 나타납니다 NSObject의 서브 클래스에 인스턴스로 보내 클래스를 호출 [Wood_Factory___Gerenciador.FotoProduto setFoto:]: unrecognized selector sent to instance 0x6080000055a0스위프트 OSX 값

작업을

:
@IBAction func selecionarFotosButtonClicked(_ sender: NSButton) { 

     let panel = NSOpenPanel() 
     panel.canChooseFiles = true 
     panel.canChooseDirectories = false 
     panel.allowsMultipleSelection = true 
     panel.canCreateDirectories = false 
     panel.allowedFileTypes = NSImage.imageTypes 

     panel.beginSheetModal(for: view.window!) { (result) in 

      if result.rawValue == NSFileHandlingPanelOKButton { 
       for url in panel.urls { 
        let fotoNSImage = NSImage(byReferencing: url) 
        let fotoNSImageRedim = Ferramentas.redimensionaNSImage(imagem: fotoNSImage, tamanho: NSSize(width: 200, height: 200)) 
        let fotoNSImageRep = NSBitmapImageRep(data: (fotoNSImageRedim.tiffRepresentation)!) 
        let fotoNSImagePng = fotoNSImageRep?.representation(using: NSBitmapImageRep.FileType.png, properties: [:]) 

        //let fotoProduto = FotoProduto(foto: PFFile(data: fotoNSImagePng!)!, categorias: []) 
        let fotoProduto = FotoProduto() 
        fotoProduto.foto = PFFile(data: fotoNSImagePng!) 
        fotoProduto.categorias = [] 
        fotoProduto.imagemCapa = false 

        self.projeto?.fotos = [FotoProduto]() 
        self.projeto?.fotos.append(fotoProduto) 
       } 

       self.verificaCapaDefinida() 

       if !self.capaDefinida { 
        let indiceImagem = IndexPath(item: 0, section: 0) 

        self.definirImagemCapa(indice: indiceImagem, limparSelecao: true) 
       } else { 
        self.fotosProjetoCollectionView.deselectAll(self) 
        self.fotosProjetoCollectionView.reloadData() 
       } 
      } 
     } 
    } 

FotoProduto 클래스 다음

import Cocoa 

import Parse 

class FotoProduto: NSObject { 

    @NSManaged var foto: PFFile? 
    @NSManaged var categorias: [String] 
    @NSManaged var imagemCapa: Bool 

    override init() { 
     super.init() 
    } 
} 

는 전체 오류입니다

2017-09-21 07:13:58.074278-0400 Wood Factory - Gerenciador[1241:101761] -[Wood_Factory___Gerenciador.FotoProduto setFoto:]: unrecognized selector sent to instance 0x6080000055a0 2017-09-21 07:13:58.478223-0400 Wood Factory - Gerenciador[1241:101761] [General] -[Wood_Factory___Gerenciador.FotoProduto setFoto:]: unrecognized selector sent to instance 0x6080000055a0 2017-09-21 07:13:58.482745-0400 Wood Factory - Gerenciador[1241:101761] [General] ( 0 CoreFoundation 0x00007fff930452cb exceptionPreprocess + 171 1 libobjc.A.dylib 0x00007fffa7e5d48d objc_exception_throw + 48 2 CoreFoundation
0x00007fff930c6f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132 3 CoreFoundation 0x00007fff92fb7755 ___forwarding_
+ 1061 4 CoreFoundation 0x00007fff92fb72a8 _CF_forwarding_prep_0 + 120 5 Wood Factory - Gerenciador 0x000000010003e68c _T026Wood_Factory___Gerenciador30GerenciarProjetoViewControllerC28selecionarFotosButtonClickedySo8NSButtonCFySo13NSApplicationC13ModalResponseVcfU_ + 1948 6 Wood Factory - Gerenciador 0x000000010003ee78 _T026Wood_Factory___Gerenciador30GerenciarProjetoViewControllerC28selecionarFotosButtonClickedySo8NSButtonCFySo13NSApplicationC13ModalResponseVcfU_TA + 88 7 Wood Factory - Gerenciador 0x000000010000ba01 _T0So13NSApplicationC13ModalResponseVIxy_ADIyBy_TR + 49 8 AppKit 0x00007fff911b78b9 -[NSSavePanel _didEndSheet:returnCode:contextInfo:] + 95 9 AppKit 0x00007fff90d25b84 -[NSWindow _endWindowBlockingModalSession:returnCode:] + 308 10 AppKit 0x00007fff911ba073 -[NSSavePanel ok:] + 461 11 libsystem_trace.dylib 0x00007fffa89753a7 _os_activity_initiate_impl + 53 12 AppKit 0x00007fff91232721 -[NSApplication(NSResponder) sendAction:to:from:] + 456 13 AppKit 0x00007fff90d16cc4 -[NSControl sendAction:to:] + 86 14 AppKit 0x00007fff90d16bec __26-[NSCell _sendActionFrom:]_block_invoke + 136 15 libsystem_trace.dylib 0x00007fffa89753a7 _os_activity_initiate_impl + 53 16 AppKit 0x00007fff90d16b44 -[NSCell _sendActionFrom:] + 128 17 AppKit
0x00007fff90d59539 -[NSButtonCell _sendActionFrom:] + 98 18 libsystem_trace.dylib 0x00007fffa89753a7 _os_activity_initiate_impl + 53 19 AppKit 0x00007fff90d15426 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2481 20 AppKit 0x00007fff90d59272 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 798 21 AppKit 0x00007fff90d13ddb -[NSControl mouseDown:] + 832 22 AppKit
0x00007fff913ae24f -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 6341 23 AppKit 0x00007fff913aaa6c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 1942 24 AppKit 0x00007fff913a9f0a -[NSWindow(NSEventRouting) sendEvent:] + 541 25 AppKit 0x00007fff9122e681 -[NSApplication(NSEvent) sendEvent:] + 1145 26 AppKit 0x00007fff90aa9427 -[NSApplication run] + 1002 27 AppKit
0x00007fff90a73e0e NSApplicationMain + 1237 28 Wood Factory - Gerenciador 0x000000010005038d main + 13 29 libdyld.dylib
0x00007fffa8743235 start + 1)

+0

CoreData를 사용하고 계십니까? – Larme

+0

아니요, CoreData를 사용하지 않습니다 – GuiDupas

+1

NSManagedObject (CoreData 용)에 대해 @ NSManaged가 아니십니까? – Larme

답변

0

이 솔루션은 PFObject의 하위 클래스를 만듭니다.

import Cocoa 

import Parse 

class FotoProduto: PFObject, PFSubclassing { 

    @NSManaged var foto: PFFile? 
    @NSManaged var categorias: [String] 
    @NSManaged var imagemCapa: Bool 

    override init() { 
     super.init() 
    } 

    init(foto: PFFile, categorias: [String]) { 
     super.init() 

     self.foto = foto 
     self.categorias = categorias 
     self.imagemCapa = false 
    } 

    static func parseClassName() -> String { 
     return "FotoProduto" 
    } 
}