Migrate to Swift 4.

pull/1/head
Matthew Chen 7 years ago
parent b2b62880c0
commit 4d8c764789

@ -912,7 +912,7 @@ static NSTimeInterval launchStartedAt;
- (void)application:(UIApplication *)application
handleActionWithIdentifier:(NSString *)identifier
forLocalNotification:(UILocalNotification *)notification
completionHandler:(void (^)(void))completionHandler
completionHandler:(void (^)())completionHandler
{
OWSAssertIsOnMainThread();
@ -939,7 +939,7 @@ static NSTimeInterval launchStartedAt;
handleActionWithIdentifier:(NSString *)identifier
forLocalNotification:(UILocalNotification *)notification
withResponseInfo:(NSDictionary *)responseInfo
completionHandler:(void (^)(void))completionHandler
completionHandler:(void (^)())completionHandler
{
OWSAssertIsOnMainThread();

@ -7,7 +7,7 @@ import PromiseKit
import SignalServiceKit
@objc(OWSMessageFetcherJob)
class MessageFetcherJob: NSObject {
public class MessageFetcherJob: NSObject {
private var timer: Timer?
@ -16,7 +16,7 @@ class MessageFetcherJob: NSObject {
private let messageReceiver: OWSMessageReceiver
private let signalService: OWSSignalService
init(messageReceiver: OWSMessageReceiver, networkManager: TSNetworkManager, signalService: OWSSignalService) {
@objc public init(messageReceiver: OWSMessageReceiver, networkManager: TSNetworkManager, signalService: OWSSignalService) {
self.messageReceiver = messageReceiver
self.networkManager = networkManager
self.signalService = signalService
@ -58,7 +58,7 @@ class MessageFetcherJob: NSObject {
return promise
}
@objc func run() -> AnyPromise {
@objc public func run() -> AnyPromise {
return AnyPromise(run())
}

@ -29,7 +29,7 @@ import SignalMessaging
self.profileManager = profileManager
}
class func run(profileKey: OWSAES256Key, identityManager: OWSIdentityManager, messageSender: MessageSender, profileManager: OWSProfileManager) {
@objc public class func run(profileKey: OWSAES256Key, identityManager: OWSIdentityManager, messageSender: MessageSender, profileManager: OWSProfileManager) {
return self.init(profileKey: profileKey, identityManager: identityManager, messageSender: messageSender, profileManager: profileManager).run()
}

@ -64,7 +64,7 @@ public class SessionResetJob: NSObject {
}
}
class func run(contactThread: TSContactThread, messageSender: MessageSender, primaryStorage: OWSPrimaryStorage) {
@objc public class func run(contactThread: TSContactThread, messageSender: MessageSender, primaryStorage: OWSPrimaryStorage) {
let job = self.init(recipientId: contactThread.contactIdentifier(),
thread: contactThread,
messageSender: messageSender,

@ -18,8 +18,9 @@ class SyncPushTokensJob: NSObject {
return PushRegistrationManager.shared
}
var uploadOnlyIfStale = true
@objc var uploadOnlyIfStale = true
@objc
required init(accountManager: AccountManager, preferences: OWSPreferences) {
self.accountManager = accountManager
self.preferences = preferences

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -20,6 +20,7 @@ class CompareSafetyNumbersActivity: UIActivity {
var mySafetyNumbers: String?
let delegate: CompareSafetyNumbersActivityDelegate
@objc
required init(delegate: CompareSafetyNumbersActivityDelegate) {
self.delegate = delegate
super.init()
@ -48,7 +49,7 @@ class CompareSafetyNumbersActivity: UIActivity {
}
override func canPerform(withActivityItems activityItems: [Any]) -> Bool {
return stringsFrom(activityItems:activityItems).count > 0
return stringsFrom(activityItems: activityItems).count > 0
}
override func prepare(withActivityItems activityItems: [Any]) {
@ -73,7 +74,7 @@ class CompareSafetyNumbersActivity: UIActivity {
if pasteboardSafetyNumbers == mySafetyNumbers {
Logger.info("\(TAG) successfully matched safety numbers. local numbers: \(String(describing: mySafetyNumbers)) pasteboard:\(pasteboardSafetyNumbers)")
delegate.compareSafetyNumbersActivitySucceeded(activity:self)
delegate.compareSafetyNumbersActivitySucceeded(activity: self)
} else {
Logger.warn("\(TAG) local numbers: \(String(describing: mySafetyNumbers)) didn't match pasteboard:\(pasteboardSafetyNumbers)")
let error = OWSErrorWithCodeDescription(OWSErrorCode.privacyVerificationFailure,
@ -91,7 +92,7 @@ class CompareSafetyNumbersActivity: UIActivity {
var numericOnly: String?
if let regex = try? NSRegularExpression(pattern: "\\D", options: .caseInsensitive) {
numericOnly = regex.stringByReplacingMatches(in: string!, options: .withTransparentBounds, range: NSMakeRange(0, string!.count), withTemplate: "")
numericOnly = regex.stringByReplacingMatches(in: string!, options: .withTransparentBounds, range: NSRange(location: 0, length: string!.count), withTemplate: "")
}
return numericOnly

@ -52,7 +52,7 @@ class OWSLayerView: UIView {
// region b) the rectangle at which the src image should be rendered
// given a dst view or output context that will yield the
// appropriate cropping.
class CropScaleImageViewController: OWSViewController {
@objc class CropScaleImageViewController: OWSViewController {
let TAG = "[CropScaleImageViewController]"
@ -107,7 +107,7 @@ class CropScaleImageViewController: OWSViewController {
fatalError("\(#function) is unimplemented.")
}
required init(srcImage: UIImage, successCompletion : @escaping (UIImage) -> Void) {
@objc required init(srcImage: UIImage, successCompletion : @escaping (UIImage) -> Void) {
// normalized() can be slightly expensive but in practice this is fine.
self.srcImage = srcImage.normalized()
self.successCompletion = successCompletion

@ -2,7 +2,7 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
class DebugUIFileBrowser: OWSTableViewController {
@objc class DebugUIFileBrowser: OWSTableViewController {
// MARK: Dependencies
var fileManager: FileManager {
@ -12,7 +12,7 @@ class DebugUIFileBrowser: OWSTableViewController {
// MARK: Overrides
let fileURL: URL
init(fileURL: URL) {
@objc init(fileURL: URL) {
self.fileURL = fileURL
super.init(nibName: nil, bundle: nil)
@ -125,7 +125,7 @@ class DebugUIFileBrowser: OWSTableViewController {
preferredStyle: .alert)
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title:"Rename \(strongSelf.fileURL.lastPathComponent)", style:.default) { _ in
alert.addAction(UIAlertAction(title: "Rename \(strongSelf.fileURL.lastPathComponent)", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
return
@ -170,7 +170,7 @@ class DebugUIFileBrowser: OWSTableViewController {
preferredStyle: .alert)
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title:"Moving \(filename)", style:.default) { _ in
alert.addAction(UIAlertAction(title: "Moving \(filename)", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
return
@ -259,7 +259,7 @@ class DebugUIFileBrowser: OWSTableViewController {
let protections: [FileProtectionType] = [.none, .complete, .completeUnlessOpen, .completeUntilFirstUserAuthentication]
protections.forEach { (protection: FileProtectionType) in
actionSheet.addAction(UIAlertAction(title: "\(protection.rawValue.replacingOccurrences(of:"NSFile", with: ""))", style: .default) { (_: UIAlertAction) in
actionSheet.addAction(UIAlertAction(title: "\(protection.rawValue.replacingOccurrences(of: "NSFile", with: ""))", style: .default) { (_: UIAlertAction) in
Logger.debug("\(strongSelf.logTag) chose protection: \(protection) for file: \(fileURL)")
let fileAttributes: [FileAttributeKey: Any] = [.protectionKey: protection]
do {
@ -288,7 +288,7 @@ class DebugUIFileBrowser: OWSTableViewController {
preferredStyle: .alert)
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title:"Create", style:.default) { _ in
alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
return
@ -326,7 +326,7 @@ class DebugUIFileBrowser: OWSTableViewController {
preferredStyle: .alert)
alert.addAction(OWSAlerts.cancelAction)
alert.addAction(UIAlertAction(title:"Create", style:.default) { _ in
alert.addAction(UIAlertAction(title: "Create", style: .default) { _ in
guard let textField = alert.textFields?.first else {
owsFail("missing text field")
return

@ -19,12 +19,15 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
let installUrl = "https://signal.org/install/"
let homepageUrl = "https://signal.org"
@objc
let actionSheetController: UIAlertController
@objc
let presentingViewController: UIViewController
let contactsManager: OWSContactsManager
var channel: Channel?
@objc
required init(presentingViewController: UIViewController, contactsManager: OWSContactsManager) {
self.presentingViewController = presentingViewController
self.contactsManager = contactsManager
@ -165,6 +168,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
}
}
@objc
public func sendSMSTo(phoneNumbers: [String]) {
if #available(iOS 10.0, *) {
// iOS10 message compose view doesn't respect some system appearence attributes.

@ -203,6 +203,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
Logger.debug("\(logTag) deinit")
}
@objc
init(thread: TSThread, uiDatabaseConnection: YapDatabaseConnection, options: MediaGalleryOption = []) {
self.thread = thread
assert(uiDatabaseConnection.isInLongLivedReadTransaction())
@ -397,6 +398,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
// e.g. the conversation settings view controller
var fromNavController: OWSNavigationController?
@objc
func pushTileView(fromNavController: OWSNavigationController) {
var mostRecentItem: MediaGalleryItem?
self.uiDatabaseConnection.read { transaction in

@ -13,6 +13,7 @@ public class GalleryItemBox: NSObject {
self.value = value
}
@objc
public var attachmentStream: TSAttachmentStream {
return value.attachmentStream
}

@ -6,7 +6,7 @@ import Foundation
import SignalServiceKit
import SignalMessaging
@objc enum MessageReceiptStatus: Int {
@objc public enum MessageReceiptStatus: Int {
case uploading
case sending
case sent
@ -25,7 +25,8 @@ public class MessageRecipientStatusUtils: NSObject {
}
// This method is per-recipient.
class func recipientStatus(outgoingMessage: TSOutgoingMessage,
@objc
public class func recipientStatus(outgoingMessage: TSOutgoingMessage,
recipientState: TSOutgoingMessageRecipientState,
referenceView: UIView) -> MessageReceiptStatus {
let (messageReceiptStatus, _, _) = recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage,
@ -143,6 +144,7 @@ public class MessageRecipientStatusUtils: NSObject {
}
// This method is per-message.
@objc
public class func receiptMessage(outgoingMessage: TSOutgoingMessage,
referenceView: UIView) -> String {
let (_, message ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage,
@ -151,7 +153,8 @@ public class MessageRecipientStatusUtils: NSObject {
}
// This method is per-message.
class func recipientStatus(outgoingMessage: TSOutgoingMessage, referenceView: UIView) -> MessageReceiptStatus {
@objc
public class func recipientStatus(outgoingMessage: TSOutgoingMessage, referenceView: UIView) -> MessageReceiptStatus {
let (status, _ ) = receiptStatusAndMessage(outgoingMessage: outgoingMessage,
referenceView: referenceView)
return status

@ -259,6 +259,7 @@ private class SignalCallData: NSObject {
}
}
@objc
var call: SignalCall? {
get {
SwiftAssertIsOnMainThread(#function)
@ -1251,6 +1252,7 @@ private class SignalCallData: NSObject {
}
}
@objc
func handleCallKitStartVideo() {
SwiftAssertIsOnMainThread(#function)

@ -9,13 +9,13 @@ import SignalMessaging
/**
* Creates an outbound call via WebRTC.
*/
@objc class OutboundCallInitiator: NSObject {
@objc public class OutboundCallInitiator: NSObject {
let TAG = "[OutboundCallInitiator]"
let contactsManager: OWSContactsManager
let contactsUpdater: ContactsUpdater
init(contactsManager: OWSContactsManager, contactsUpdater: ContactsUpdater) {
@objc public init(contactsManager: OWSContactsManager, contactsUpdater: ContactsUpdater) {
self.contactsManager = contactsManager
self.contactsUpdater = contactsUpdater
@ -27,7 +27,7 @@ import SignalMessaging
/**
* |handle| is a user formatted phone number, e.g. from a system contacts entry
*/
public func initiateCall(handle: String) -> Bool {
@objc public func initiateCall(handle: String) -> Bool {
Logger.info("\(TAG) in \(#function) with handle: \(handle)")
guard let recipientId = PhoneNumber(fromE164: handle)?.toE164() else {
@ -41,7 +41,7 @@ import SignalMessaging
/**
* |recipientId| is a e164 formatted phone number.
*/
public func initiateCall(recipientId: String,
@objc public func initiateCall(recipientId: String,
isVideo: Bool) -> Bool {
// Rather than an init-assigned dependency property, we access `callUIAdapter` via Environment
// because it can change after app launch due to user settings

@ -42,6 +42,8 @@ protocol CallObserver: class {
let TAG = "[SignalCall]"
var observers = [Weak<CallObserver>]()
@objc
let remotePhoneNumber: String
var isTerminated: Bool {
@ -59,6 +61,7 @@ protocol CallObserver: class {
let direction: CallDirection
// Distinguishes between calls locally, e.g. in CallKit
@objc
let localId: UUID
let thread: TSContactThread

@ -19,6 +19,8 @@ final class CallKitCallManager: NSObject {
let callController = CXCallController()
let showNamesOnCallScreen: Bool
@objc
static let kAnonymousCallHandlePrefix = "Signal:"
required init(showNamesOnCallScreen: Bool) {

@ -7,7 +7,7 @@ import SignalServiceKit
import SignalMessaging
@objc(OWSWebRTCCallMessageHandler)
class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler {
public class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler {
// MARK - Properties
@ -21,7 +21,7 @@ class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler {
// MARK: Initializers
required init(accountManager: AccountManager, callService: CallService, messageSender: MessageSender) {
@objc public required init(accountManager: AccountManager, callService: CallService, messageSender: MessageSender) {
self.accountManager = accountManager
self.callService = callService
self.messageSender = messageSender

@ -13,7 +13,7 @@ enum ExperienceUpgradeId: String {
introducingCustomNotificationAudio = "005"
}
class ExperienceUpgradeFinder: NSObject {
@objc public class ExperienceUpgradeFinder: NSObject {
// MARK - Singleton class
@ -79,11 +79,11 @@ class ExperienceUpgradeFinder: NSObject {
// MARK: - Instance Methods
public func allUnseen(transaction: YapDatabaseReadTransaction) -> [ExperienceUpgrade] {
@objc public func allUnseen(transaction: YapDatabaseReadTransaction) -> [ExperienceUpgrade] {
return allExperienceUpgrades.filter { ExperienceUpgrade.fetch(uniqueId: $0.uniqueId!, transaction: transaction) == nil }
}
public func markAllAsSeen(transaction: YapDatabaseReadWriteTransaction) {
@objc public func markAllAsSeen(transaction: YapDatabaseReadWriteTransaction) {
Logger.info("\(logTag) marking experience upgrades as seen")
allExperienceUpgrades.forEach { $0.save(with: transaction) }
}

@ -24,6 +24,7 @@ class AttachmentPointerView: UIView {
}
}
@objc
required init(attachmentPointer: TSAttachmentPointer, isIncoming: Bool) {
self.isIncoming = isIncoming
self.attachmentPointer = attachmentPointer

@ -14,7 +14,7 @@ class PanDirectionGestureRecognizer: UIPanGestureRecognizer {
let direction: PanDirection
init(direction: PanDirection, target: AnyObject, action: Selector) {
@objc init(direction: PanDirection, target: AnyObject, action: Selector) {
self.direction = direction
super.init(target: target, action: action)

@ -51,6 +51,7 @@ import SignalServiceKit
fatalError("init(coder:) has not been implemented")
}
@objc
public func configure(thread: TSGroupThread, contactsManager: OWSContactsManager) {
if let groupName = thread.groupModel.groupName, !groupName.isEmpty {
self.nameLabel.text = groupName

@ -11,12 +11,14 @@ protocol QuotedReplyPreviewDelegate: class {
@objc
class QuotedReplyPreview: UIView {
@objc
public weak var delegate: QuotedReplyPreviewDelegate?
private let quotedReply: OWSQuotedReplyModel
private var quotedMessageView: OWSQuotedMessageView?
private var heightConstraint: NSLayoutConstraint!
@objc
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

@ -13,12 +13,14 @@ protocol OWSVideoPlayerDelegate: class {
@objc
public class OWSVideoPlayer: NSObject {
@objc
let avPlayer: AVPlayer
let audioActivity: AudioActivity
@objc
weak var delegate: OWSVideoPlayerDelegate?
init(url: URL) {
@objc init(url: URL) {
self.avPlayer = AVPlayer(url: url)
self.audioActivity = AudioActivity(audioDescription: "[OWSVideoPlayer] url:\(url)")
@ -32,11 +34,13 @@ public class OWSVideoPlayer: NSObject {
// MARK: Playback Controls
@objc
public func pause() {
avPlayer.pause()
OWSAudioSession.shared.endAudioActivity(self.audioActivity)
}
@objc
public func play() {
OWSAudioSession.shared.startPlaybackAudioActivity(self.audioActivity)
@ -53,6 +57,7 @@ public class OWSVideoPlayer: NSObject {
avPlayer.play()
}
@objc
public func stop() {
avPlayer.pause()
avPlayer.seek(to: kCMTimeZero)

@ -75,6 +75,7 @@ public class PlayerProgressBar: UIView {
private let kPreferredTimeScale: CMTimeScale = 100
@objc
public var player: AVPlayer? {
didSet {
guard let item = player?.currentItem else {

@ -157,10 +157,12 @@ extension String {
@objc public let isTextTruncated: Bool
@objc public let jumbomojiCount: UInt
@objc
static let kMaxJumbomojiCount: UInt = 5
// This value is a bit arbitrary since we don't need to be 100% correct about
// rendering "Jumbomoji". It allows us to place an upper bound on worst-case
// performacne.
@objc
static let kMaxCharactersPerEmojiCount: UInt = 10
// MARK: Initializers

@ -20,26 +20,31 @@ public class OWSMessagesBubbleImageFactory: NSObject {
return UIView().isRTL()
}()
@objc
public lazy var incoming: JSQMessagesBubbleImage = {
let color = OWSMessagesBubbleImageFactory.bubbleColorIncoming
return self.incoming(color: color)
}()
@objc
public lazy var outgoing: JSQMessagesBubbleImage = {
let color = OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent
return self.outgoing(color: color)
}()
@objc
public lazy var currentlyOutgoing: JSQMessagesBubbleImage = {
let color = OWSMessagesBubbleImageFactory.bubbleColorOutgoingSending
return self.outgoing(color: color)
}()
@objc
public lazy var outgoingFailed: JSQMessagesBubbleImage = {
let color = OWSMessagesBubbleImageFactory.bubbleColorOutgoingUnsent
return self.outgoing(color: color)
}()
@objc
public func bubble(message: TSMessage) -> JSQMessagesBubbleImage {
if message is TSIncomingMessage {
return self.incoming
@ -70,6 +75,7 @@ public class OWSMessagesBubbleImageFactory: NSObject {
@objc
public static let bubbleColorOutgoingSent = UIColor.ows_materialBlue
@objc
public func bubbleColor(message: TSMessage) -> UIColor {
if message is TSIncomingMessage {
return OWSMessagesBubbleImageFactory.bubbleColorIncoming

@ -60,6 +60,7 @@ import Foundation
}
@objc public class MediaStrings: NSObject {
@objc
static public let allMedia = NSLocalizedString("MEDIA_DETAIL_VIEW_ALL_MEDIA_BUTTON", comment: "nav bar button item")
}

Loading…
Cancel
Save