diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 1ddb7a1b..e75b959a 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -229,7 +229,7 @@ 50F2B9781B2EDF3D00F840CC /* BorderTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F2B9771B2EDF3D00F840CC /* BorderTextField.swift */; }; 50F2B97B1B2EEAF800F840CC /* NavigationTitleLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F2B97A1B2EEAF800F840CC /* NavigationTitleLabel.swift */; }; 50FA9A441B661698009BF2A0 /* UIViewController+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50FA9A431B661698009BF2A0 /* UIViewController+Yep.swift */; }; - 6A649A9B1BB259CB00EE4FB5 /* YepSoundEffectHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A649A9A1BB259CB00EE4FB5 /* YepSoundEffectHelper.swift */; settings = {ASSET_TAGS = (); }; }; + 6A649A9B1BB259CB00EE4FB5 /* YepSoundEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A649A9A1BB259CB00EE4FB5 /* YepSoundEffect.swift */; settings = {ASSET_TAGS = (); }; }; 6A649A9D1BB25BF100EE4FB5 /* bub3.caf in Resources */ = {isa = PBXBuildFile; fileRef = 6A649A9C1BB25BF100EE4FB5 /* bub3.caf */; settings = {ASSET_TAGS = (); }; }; 6ADDB4501B848C600012877A /* 1Password.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6ADDB44F1B848C600012877A /* 1Password.xcassets */; }; 8409137D1B7DB173001C89D6 /* FriendRequestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8409137C1B7DB173001C89D6 /* FriendRequestView.swift */; }; @@ -489,7 +489,7 @@ 50F2B9771B2EDF3D00F840CC /* BorderTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BorderTextField.swift; path = Views/TextFields/BorderTextField.swift; sourceTree = ""; }; 50F2B97A1B2EEAF800F840CC /* NavigationTitleLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NavigationTitleLabel.swift; path = Views/Labels/NavigationTitleLabel.swift; sourceTree = ""; }; 50FA9A431B661698009BF2A0 /* UIViewController+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIViewController+Yep.swift"; path = "Extensions/UIViewController+Yep.swift"; sourceTree = ""; }; - 6A649A9A1BB259CB00EE4FB5 /* YepSoundEffectHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepSoundEffectHelper.swift; path = Helpers/YepSoundEffectHelper.swift; sourceTree = ""; }; + 6A649A9A1BB259CB00EE4FB5 /* YepSoundEffect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepSoundEffect.swift; path = Helpers/YepSoundEffect.swift; sourceTree = ""; }; 6A649A9C1BB25BF100EE4FB5 /* bub3.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = bub3.caf; sourceTree = ""; }; 6ADDB44F1B848C600012877A /* 1Password.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = 1Password.xcassets; sourceTree = ""; }; 8409137C1B7DB173001C89D6 /* FriendRequestView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FriendRequestView.swift; path = Views/FriendRequest/FriendRequestView.swift; sourceTree = ""; }; @@ -1027,7 +1027,7 @@ 50EB8C5D1AE78AB9001AC1EE /* YepAsset.swift */, 50894D0F1AEE3C25000981AF /* YepHUD.swift */, 508DF62A1B9985F300B194A4 /* YepLog.swift */, - 6A649A9A1BB259CB00EE4FB5 /* YepSoundEffectHelper.swift */, + 6A649A9A1BB259CB00EE4FB5 /* YepSoundEffect.swift */, ); name = Helpers; sourceTree = ""; @@ -1975,7 +1975,7 @@ 500A0B1C1B450C2100D49358 /* EditNicknameAndBadgeViewController.swift in Sources */, 501560D71B427FD6000933F0 /* Results+Yep.swift in Sources */, 0AEB1CC61B0E742400178C9C /* Double+Yep.swift in Sources */, - 6A649A9B1BB259CB00EE4FB5 /* YepSoundEffectHelper.swift in Sources */, + 6A649A9B1BB259CB00EE4FB5 /* YepSoundEffect.swift in Sources */, 508D174C1ACCF49B0092D666 /* ChatRightAudioCell.swift in Sources */, 502AE53D1AB87C0D005BD199 /* YepUserDefaults.swift in Sources */, 50EB8CC41AE89F12001AC1EE /* ChatRightVideoCell.swift in Sources */, diff --git a/Yep/Helpers/YepSoundEffectHelper.swift b/Yep/Helpers/YepSoundEffect.swift similarity index 89% rename from Yep/Helpers/YepSoundEffectHelper.swift rename to Yep/Helpers/YepSoundEffect.swift index 13f483f6..82abf808 100644 --- a/Yep/Helpers/YepSoundEffectHelper.swift +++ b/Yep/Helpers/YepSoundEffect.swift @@ -6,10 +6,10 @@ // Copyright © 2015年 Catch Inc. All rights reserved. // -import UIKit import AudioToolbox.AudioServices -class YepSoundEffectHelper: NSObject { +class YepSoundEffect: NSObject { + var soundID: SystemSoundID? init(soundName: String) { @@ -21,9 +21,8 @@ class YepSoundEffectHelper: NSObject { if (error == kAudioServicesNoError) { soundID = theSoundID } else { - print("Sound Init Error") + println("YepSoundEffect Init Error") } - } } @@ -39,3 +38,4 @@ class YepSoundEffectHelper: NSObject { } } } + diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index 5a74610a..32302768 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -24,7 +24,7 @@ class ConversationViewController: BaseViewController { var realm: Realm! - var sendMessageSound = YepSoundEffectHelper(soundName: "bub3") + lazy var sendMessageSoundEffect: YepSoundEffect = YepSoundEffect(soundName: "bub3") lazy var messages: Results = { return messagesOfConversation(self.conversation, inRealm: self.realm) @@ -476,7 +476,7 @@ class ConversationViewController: BaseViewController { messageToolbar.textSendAction = { [weak self] messageToolbar in - self?.sendMessageSound.play() + self?.sendMessageSoundEffect.play() let text = messageToolbar.messageTextView.text!.trimming(.WhitespaceAndNewline)