Closed LaChrome closed 9 years ago
I have started to create a helper function.
Something like this should work:
import Foundation import Regift
public class RegiftHelper: NSObject { private override init() {}
public class func createGIFFromURL(URL: NSURL, withFrameCount frameCounter: Int, delayTimer: Float, loopCounter: Int = 0) -> NSURL?
{
let videoURL = URL
let frameCount = frameCounter
let delayTime = delayTimer
let loopCount = loopCounter // 0 means loop forever
let regift = Regift(sourceFileURL: videoURL, frameCount: frameCount, delayTime: delayTime, loopCount: loopCount)
print("Gif saved to \(regift.createGif())")
return regift.createGif()
}
}
For anyone looking to get Regift 1.0.1 working with an Objective C project, this is working for me:
Create a new swift file in your Objective C project with the following contents: ////////////////////// Regift Objective C Helper Class ///////////////////// import Foundation public class RegiftHelper: NSObject { private override init() {}
public class func createGIFFromURL(URL: NSURL, withFrameCount frameCounter: Int, delayTimer: Float, loopCounter: Int = 0) -> NSURL? {
let videoURL = URL
let frameCount = frameCounter
let delayTime = delayTimer
let loopCount = loopCounter // 0 means loop forever
let regift = Regift(sourceFileURL: videoURL, frameCount: frameCount, delayTime: delayTime, loopCount: loopCount)
print("Gif saved to \(regift.createGif())")
return regift.createGif()
}
} ////////////////////// End of Regift Objective C Helper Class /////////////////////
animGif = [RegiftHelper createGIFFromURL:videoURL withFrameCount:8 delayTimer:0 loopCounter:0];
I think Iām probably going to make Regift back into an @objc
class again, since there isn't much value in it being a struct since we don't get value semantics. Hopefully I will get a chance to look at this in the next couple of days :)
Thanks for your feedback!
Don't think I will get a chance to look at this @Apptation, but I'm happy to accept a PR for it if you'd like it to be in master :). The main changes are to make Regift an @objc public class
that subclasses NSObject, and to move the Constants struct to be private fields (and update the usages of these constants).
Feel free to reopen at any stage if you think more discussion is needed :)
I wasn't expecting you to add this in if you're switching the code back to a public class I've got regift up and running in Xcode7 with my objective c project, so I'm all good š Im happy to submit the change through a pull request, but if you're going to change over to a public class anyway, it would defeat the purpose. Thanks for your help. Ps. Regift is an awesome addition to my apps! Really appreciate your work on it and making it public. Chris On Sat, Sep 19, 2015 at 2:21 AM, matthewpalmer/Regift reply@reply.github.com wrote: Don't think I will get a chance to look at this @Apptation [https://github.com/Apptation] , but I'm happy to accept a PR for it if you'd like it to be in master :). The main changes are to make Regift an @objc public class that subclasses NSObject, and to move the Constants struct to be private fields (and update the usages of these constants).
Feel free to reopen at any stage if you think more discussion is needed :)
ā Reply to this email directly or view it on GitHub [https://github.com/matthewpalmer/Regift/issues/18#issuecomment-141630271] .[https://github.com/notifications/beacon/AGsyPnWqegZOhfgJ55SdzgyLTdr7mxnOks5ozPZxgaJpZM4F_oYF.gif]
Ah sorry I meant that if you wanted obj c support in master, the best way to do that would be to submit a PR making Regift a public class, rather than adding the RegiftHelper class
Ahh yes. I can have a crack at it. That helper file was the first thing I've ever coded in Swift.
Ps, I've been trying to use Pods to install Regift, and all I ever get is this error:
[!] Unable to satisfy the following requirements:
Regift
required by Podfile
Every other pod works fine.
I currently have Regift working as a Git sub module
Chris
On 19 Sep 2015, at 4:57 PM, Matthew Palmer notifications@github.com wrote:
Ah sorry I meant that if you wanted obj c support in master, the best way to do that would be to submit a PR making Regift a public class, rather than adding the RegiftHelper class
ā Reply to this email directly or view it on GitHub.
Swift Struct isn't reachable in Objective C. Regift v1.0.1 removed the "public class Regift", so it no longer works with Objective C.
I'm new to swift, but is it possible to add a public class to the Regift.swift file that then calls the respective Regift struct so that we can make this useable in Objective C again?
Chris