2016-12-27 3 views
0

を割り当てることができない私は現在JSQMessageViewControllerを使用してプロジェクトに取り組んでいると エラーrequired method not implemented: -[JSQMessagesViewController senderId]'を取得しますが、私はviewDidLoadself.senderIdに文字列値を代入しようとしたとき、それは私ができるというエラーを返します。プロパティに割り当てません:senderIdはメソッドです。どのようにこの問題に取り組むべきですか?Q:SENDERIDがメソッドであると

答えて

1

JSQMessagesViewControllerサブクラスでsenderIdメソッドをオーバーライドし、現在の送信者の一意の識別子を返す必要があります。 here(に準拠したJSQMessagesViewControllerJSQMessagesCollectionViewDataSourceのドキュメントを参照してください。

/** 
* Asks the data source for the current sender's unique identifier, that is, the 
* current user who is sending messages. 
* 
* @return An initialized string identifier that uniquely identifies the current 
*   sender. 
* 
* @warning You must not return `nil` from this method. This value must be unique. 
*/ 
- (NSString *)senderId; 

また、JSQMessagesViewController.mを見て、あなたはサブクラスでオーバーライドする必要があるすべてのメソッドを見つけることNSAssertを検索します。

+0

私はsenderId関数をオーバーライドしようとしましたが、 'メソッドはそのスーパークラスのメソッドをオーバーライドしませんでした.'これを行う方法の例を表示できますか? –

+0

View Controllerは 'JSQMessagesViewController'のサブクラスですか?これらのメソッドをオーバーライドするには、サブクラス化する必要があります。このようなサブクラスのスウィフト例があります:https://github.com/jessesquires/JSQMessagesViewController/blob/develop/SwiftExample/SwiftExample/ChatViewController.swift – TylerTheCompiler

+0

はい、例とまったく同じです。ここで私が持っているものです。 '輸入のUIKit インポートJSQMessagesViewController クラスChatViewController:JSQMessagesViewController { は、のviewDidLoad(){ super.viewDidLoad()SENDERID()FUNC } オーバーライドfuncを送信者= "名前" オーバーライドしてみましょう - >文字列{ リターンセンダー } } –

関連する問題