This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| + (NSString*)stringByRemovingEmojiFrom:(NSString*)string { | |
| NSMutableString* __block buffer = [NSMutableString stringWithCapacity:[string length]]; | |
| [string enumerateSubstringsInRange:NSMakeRange(0, [string length]) | |
| options:NSStringEnumerationByComposedCharacterSequences | |
| usingBlock: ^(NSString* substring, NSRange substringRange, NSRange enclosingRange, BOOL* stop) { | |
| [buffer appendString:([[self class] isEmoji:substring])? @"": substring]; | |
| }]; | |
| return buffer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func tableView(_ tableView: UITableView, | |
| cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| // Clean up | |
| if [self.subviews containsObject: self.someNotoriousView] { | |
| [self.contentView removeFromSuperview]; | |
| } | |
| // Set up(adding that notorious view again based on some condition ) | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func tableView(_ tableView: UITableView, | |
| cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| // Set up(adding that notoroious view again based on some condition ) | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func prepareForReuse() { | |
| // Clean up | |
| if [self.subviews containsObject: self.someNotoriousView] { | |
| [self.contentView removeFromSuperview]; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func play(sound: String, ofType type: SoundExtension) { | |
| if let soundID = notificationSoundLookupTable[sound] { | |
| AudioServicesPlaySystemSound(soundID) | |
| } else { | |
| if let soundURL : CFURL = Bundle.main.url(forResource: sound, withExtension: type.rawValue) as CFURL? { | |
| var soundID : SystemSoundID = 0 | |
| let osStatus : OSStatus = AudioServicesCreateSystemSoundID(soundURL, &soundID) | |
| if osStatus == kAudioServicesNoError { | |
| AudioServicesPlaySystemSound(soundID); | |
| notificationSoundLookupTable[sound] = (soundID) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum SoundExtension : String{ | |
| case caf | |
| case aif | |
| case wav | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var notificationSoundLookupTable = [String: SystemSoundID]() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func disposeSoundIDs() { | |
| for soundID in notificationSoundLookupTable.values { | |
| AudioServicesDisposeSystemSoundID(soundID) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| play(sound: "ShortRing", ofType: .wav) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NMView: UIView { | |
| @IBInspectable var text: String? { | |
| didSet { label.text = text } | |
| } | |
| var label: UILabel! | |
| } |
OlderNewer