SvenTiigi / WhatsNewKit

Showcase your awesome new app features 📱
https://sventiigi.github.io/WhatsNewKit/
MIT License
3.92k stars 193 forks source link

Objective-C Support #8

Closed ghost closed 6 years ago

ghost commented 6 years ago

Can you include an example for using your component on Objective-c?

SvenTiigi commented 6 years ago

Hey @ahamedsaifudeen

Currently WhatsNewKit doesn't support Objective-C.

In order to make WhatsNewKit compatible with Objective-C a lot of existing code must be refactored. For example all WhatsNew structs must be refactored to classes to make them visible in an Objective-C environment.

ghost commented 6 years ago

@SvenTiigi

Understand the complexity. Thanks for the quick response.

mikemaat commented 5 years ago

If you write yourself a wrapper .swift file, you can use it in an Objective C project (assuming you've already setup support for having both ObjC and Swift in the same project)

Screenshot 2019-11-06 17 27 11

Screenshot 2019-11-06 17 27 45

ghost commented 4 years ago

@mikemaat Thanks a lot. This is very helpful. I have added this and it works great.

@SvenTiigi It might be helpful to include this.

EpicDraws commented 4 years ago

This works great! You'll just need to create this as WhatsNewObjcWrapper.swift, then import -Swift.h (which is autogenerated by Xcode).

In case this saves anyone time, here is the code from the image above in copy/pastable text form:

import Foundation
import WhatsNewKit

@objc class WhatsNewObjcWrapper: UIViewController {
    @objc static func getWhatsNewViewController() -> UIViewController {
        let whatsNew = WhatsNew(title: "New!",
                                items: [
                                    WhatsNew.Item(
                                        title: "<Your Title>",
                                        subtitle: "Your Description",
                                        image: UIImage(named: "your-image")
                                    ),
                                    WhatsNew.Item(
                                        title: "<Your Title>",
                                        subtitle: "Your Description",
                                        image: UIImage(named: "your-image")
                                    ),
                                    WhatsNew.Item(
                                        title: "<Your Title>",
                                        subtitle: "Your Description",
                                        image: UIImage(named: "your-image")
                                    ),
                                ]
        )

        let whatsNewViewController = WhatsNewViewController(whatsNew: whatsNew)

        return whatsNewViewController
    }
}

UIViewController* whatsNewController = [WhatsNewObjcWrapper getWhatsNewViewController];
    [self.navigationController presentViewController:whatsNewController animated:true completion:nil];