2017-01-24 26 views
0

XMPPMessageArchiving_Message_CoreDataObject class斯威夫特3 XMPPframework正確使用

import UIKit 

open class XMPPMessageArchiving_Message_CoreDataObject : NSManagedObject { 
    open var message: XMPPMessage! // Transient (proper type, not on disk) 

    open var messageStr: String! // Shadow (binary data, written to disk) 


    /** 
    * This is the bare jid of the person you're having the conversation with. 
    * For example: [email protected] 
    * 
    * Regardless of whether the message was incoming or outgoing, 
    * this will represent the "other" participant in the conversation. 
    **/ 

    open var bareJid: XMPPJID! // Transient (proper type, not on disk) 

    open var bareJidStr: String! // Shadow (binary data, written to disk) 


    open var body: String! 

    open var thread: String! 


    open var outgoing: NSNumber! // Use isOutgoing 

    open var isOutgoing: Bool // Convenience property 


    open var composing: NSNumber! // Use isComposing 

    open var isComposing: Bool // Convenience property 


    open var timestamp: Date! 


    open var streamBareJidStr: String! 


    /** 
    * This method is called immediately before the object is inserted into the managedObjectContext. 
    * At this point, all normal properties have been set. 
    * 
    * If you extend XMPPMessageArchiving_Message_CoreDataObject, 
    * you can use this method as a hook to set your custom properties. 
    **/ 
    open func willInsert() 


    /** 
     * This method is called immediately after the message has been changed. 
     * At this point, all normal properties have been updated. 
     * 
     * If you extend XMPPMessageArchiving_Message_CoreDataObject, 
     * you can use this method as a hook to set your custom properties. 
     **/ 
     open func didUpdate() 

} 

嗨,

我和斯威夫特3和XMPPframework相當新,我試圖增加新XMPPMessageArchiving_Message數據模型核心數據中的列記錄了我的用例的其他數據,在該類中聲明您需要擴展以添加自定義屬性。看來,班級的延伸對我來說不起作用。下面的示例擴展模塊測試willInsert()

willInsert Test

extension XMPPMessageArchiving_Contact_CoreDataObject { 

    open func willInsert(){ 
     print("In willInsert()") 
     //to-do additional data 
    } 

} 

這是調用鉤子在類中提到的正確方法是什麼?

在此先感謝您的答覆..

+0

請用代碼標記張貼您的代碼作爲文本,而不是作爲圖像 – JimHawkins

回答

0

對於這種情況,我做了一個擴展類和overrideXMPPMessageArchiving_Contact_CoreDataObject如下

extension XMPPMessageArchiving_Contact_CoreDataObject{ 
     open override func willSave(){ 

     \\Your code here before you insert 

     } 
    }