Custom NSValueTransformer in xcode 6 with swift

后端 未结 2 1331
一向
一向 2021-02-07 07:14

Did anyone successfully implement a custom NSValueTransformer in xcode 6 beta with swift?

I have the following swift class:

import Foundation

class myTr         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 07:54

    After you initialise newTransformer you should also include the line:

    NSValueTransformer.setValueTransformer(newTransformer, forName: "myTransformer")
    

    Then in your Interface Builder you should use myTransformer instead of newTransformer under the Value Transformer dropdown.

提交回复
热议问题