谢谢吕克
这是代码.
import UIKitimport JsQMessagesVIEwControllerimport syncano_ioslet syncanoChannelname = "messages"class VIEwController: JsQMessagesVIEwController {let syncano = Syncano.sharedInstanceWithAPIKey("7f5312e4808d69df6bd258b444b13d5d5956c15d",instancename: "small-waterfall-9948")let channel = SCChannel(name: syncanoChannelname)let incomingBubble = JsQMessagesBubbleImageFactory().incomingMessagesBubbleImageWithcolor(UIcolor(red: 10/255,green: 180/255,blue: 230/255,Alpha: 1.0))let outgoingBubble = JsQMessagesBubbleImageFactory().outgoingMessagesBubbleImageWithcolor(UIcolor.lightGraycolor())var messages = [JsQMessage]()overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. self.setup() self.downloadNewestMessagesFromSyncano()}overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated.}func reloadMessagesVIEw() { self.collectionVIEw?.reloadData()}}//MARK - Setupextension VIEwController {func addDemoMessages() { for i in 1...10 { let sender = (i%2 == 0) ? "Server" : self.senderID let messageContent = "Message nr. \(i)" let message = JsQMessage(senderID: sender,displayname: sender,text: messageContent) self.messages += [message] } self.reloadMessagesVIEw()}func setup() { self.senderID = UIDevice.currentDevice().IDentifIErForvendor?.UUIDString self.senderdisplayname = UIDevice.currentDevice().IDentifIErForvendor?.UUIDString self.channel.delegate = self self.channel.subscribetochannel()}}//MARK - Data Sourceextension VIEwController {overrIDe func collectionVIEw(collectionVIEw: UICollectionVIEw,numberOfItemsInSection section: Int) -> Int { return self.messages.count}overrIDe func collectionVIEw(collectionVIEw: JsQMessagesCollectionVIEw!,messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JsQMessageData! { let data = self.messages[indexPath.row] return data}overrIDe func collectionVIEw(collectionVIEw: JsQMessagesCollectionVIEw!,dIDDeleteMessageAtIndexPath indexPath: NSIndexPath!) { self.messages.removeAtIndex(indexPath.row)}overrIDe func collectionVIEw(collectionVIEw: JsQMessagesCollectionVIEw!,messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JsQMessageBubbleImageDataSource! { let data = messages[indexPath.row] switch(data.senderID) { case self.senderID: return self.outgoingBubble default: return self.incomingBubble }}overrIDe func collectionVIEw(collectionVIEw: JsQMessagesCollectionVIEw!,avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JsQMessageAvatarImageDataSource! { return nil}}//MARK - Toolbarextension VIEwController {overrIDe func dIDPressSendbutton(button: UIbutton!,withMessageText text: String!,senderID: String!,senderdisplayname: String!,date: NSDate!) { let message = JsQMessage(senderID: senderID,senderdisplayname: senderdisplayname,date: date,text: text) self.messages += [message] self.sendMessagetoSyncano(message) self.finishSendingMessage()}overrIDe func dIDPressAccessorybutton(sender: UIbutton!) {}}//MARK - Syncanoextension VIEwController {func sendMessagetoSyncano(message: JsQMessage) { let messagetoSend = Message() messagetoSend.text = message.text messagetoSend.senderID = self.senderID messagetoSend.channel = syncanoChannelname messagetoSend.other_permissions = .Full messagetoSend.saveWithCompletionBlock { error in if (error != nil) { //Super cool error handling } }}func downloadNewestMessagesFromSyncano() { Message.please().giveMeDataObjectsWithCompletion { objects,error in if let messages = objects as? [Message]! { self.messages = self.JsqMessagesFromSyncanoMessages(messages) self.finishReceivingMessage() } }}func JsqMessageFromSyncanoMessage(message: Message) -> JsQMessage { let JsqMessage = JsQMessage(senderID: message.senderID,senderdisplayname: message.senderID,date: message.created_at,text: message.text) return JsqMessage}func JsqMessagesFromSyncanoMessages(messages: [Message]) -> [JsQMessage] { var JsqMessages : [JsQMessage] = [] for message in messages { JsqMessages.append(self.JsqMessageFromSyncanoMessage(message)) } return JsqMessages}}//MARK - Channelsextension VIEwController : SCChannelDelegate {func addMessageFromNotification(notification: SCChannelNotificationMessage) { let message = Message(fromDictionary: notification.payload) if message.senderID == self.senderID { //we don't need to add messages from ourselves return } self.messages.append(self.JsqMessageFromSyncanoMessage(message)) self.finishReceivingMessage()}func updateMessageFromNotification(notification: SCChannelNotificationMessage) {}func deleteMessageFromNotification(notification: SCChannelNotificationMessage) {}func chanellDIDReceivednotificationMessage(notificationMessage: SCChannelNotificationMessage!) { switch(notificationMessage.action) { case .Create: self.addMessageFromNotification(notificationMessage) case .Delete: self.deleteMessageFromNotification(notificationMessage) case .Update: self.updateMessageFromNotification(notificationMessage) default: break }}}执行以下 *** 作,您可以从“Pods”导入任何swift文件
1) Clean your project
2) Make sure that all your “Pods” > “Build Settings” > “Build Active
Architecture Only” is set to “NO”.3) Don’t run,just build your project.
4) Now,import any file from “Pods” to any swift file
E.g.: import JsQMessagesVIEwController
5) Again,build project and it will work as expected. Finally,you can
access it propertIEs
希望这可以帮助!
总结以上是内存溢出为你收集整理的swift – 没有这样的模块错误全部内容,希望文章能够帮你解决swift – 没有这样的模块错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)