UIView instancetype from Obj-C at Swift

449 views Asked by At

Hello everyone I'm getting close to programming Swift then feel right away that I'm new to Swift

In my project in Obj-C I created many classes UIView that I used in my app

I have a problem with the implementation of these classes UIView from Obj-C for Swift ...

In short, until now I have always used this... My class UIView had various init with frame etc ... but a directly instancetype that elaborated all

-(instancetype)initializeNotificationViewWithTitle:(NSString *)notificationTitle
                               notificationMessage:(NSString *)notificationMessage
                                  notificationType:(UTNotificationType)notificationType
                                  notificationMode:(UTNotificationMode)notificationMode 

now I can not fit it in Swift many of you surely know that Swift is the most simple of Obj-C but I still can not adapt

You can make me understand how to implement this function I posted this in Obj-C Swift ?

1

There are 1 answers

2
dopcn On BEST ANSWER

The method you provided looks like a simple init method and init method in swift looks like

init(title: String, message: String, type: UTNotificationType, mode: UTNotificationMode) {
    //init
}

and use it as

let aView = NotificationView(title:"title", message:"message", type: someType, mode: someMode)