There is still an issue with defining callbacks in CoreMIDI with Swift, so the workaround is to use Objective-C. I found this answer, but I cannot figure out how to use MIDIReadProcCallback.setOnCallback({ (packetList: MIDIPacketList) in ... }) from this answer: https://stackoverflow.com/a/26139259/616873.
I cannot comment on the specific answer for more clarification because my rep is not 50, so if anyone can point me to some sample code or further clarification, I would be very appreciative.
Here is a blog post and github repo with a working example. The Swift code uses objc as a trampoline for the function pointers.
Related
In Scalameta's tutorial, it notes that the Semantic API can be used for name resolution (println => _root_.scala.Predef.println). The FAQ "How do I use the Semantic API?" links to scalafix, but I was unable to find a tutorial or concrete examples. So I'm still unclear. Can someone point me to some specific examples or a tutorial?
Thanks!
Received the following answer from Ólafur Páll Geirsson on gitter:
you can try InteractiveSemanticdb
https://github.com/scalameta/scalameta/blob/master/scalameta/interactive/src/main/scala/scala/meta/interactive/InteractiveSemanticdb.scala
it's part of the interactive module
With it I was able to answer all my questions.
I am reviewing a code from other developers and I saw some unfamiliar codes. One of the unfamiliar code is this.
identifier <- map["id"]
identifier is a variable inside the struct. Can you please help me what is the use of "<-" symbol? I tried googling it but I can't find the right answer. Thank you!
The <- operator is not part of Swift.
There's nothing in the Swift manual about it.
It is a custom operator defined by a third-party library you're using in your project.
If you do a CMD-click on it, Xcode should open the operator's declaration
The Developer used ObjectMapper.
https://github.com/Hearst-DD/ObjectMapper
That's why. Thank you guys for answering my post here.
Cheers!
I was just wondering if there is any written documentation on realm swift for iOS 7, since it is combination of objective c and swift.
Just to be clear, I'm not looking for official documentation, just some guidelines so I have a clearer view of what to use.
Thank you for any help.
You should refer to Realm Objective-C's documentation guide (https://realm.io/docs/objc/latest) and API documentation (https://realm.io/docs/objc/latest/api), which is applicable even when used from Swift.
As our installation instructions recommend (https://realm.io/docs/objc/latest/#installation), you should also be using RLMSupport.swift which adds some useful helpers to use Realm Objective-C from Swift. That file's source is its best documentation, it's pretty small and should be fairly readable.
Finally, to determine the exact Swift syntax when calling Objective-C methods, I recommend you either use autocomplete, or command-click a Realm.framework token from Swift, which should display Xcode's auto-generated Swift interface for the Realm module.
I was wondering if you can write inline assembly in Swift.
I know that in Objective-C you could use something like this:
inline void assemblyFunc() {
__asm__(/*Assembly*/);
}
But in Swift it seems that you can't use __asm__(/*Assembly*/).
Does anyone know how to use __asm__() if its even possible.
I haven't found anything about it, so I thought it would be a good question to ask.
There isn't a way in Swift itself. If you need this, probably a good opportunity to take advantage of Swift-ObjC interop.
To expand on what Robert Levy said, you can just use the Swift/Obj-C interop feature, and write an Obj-C class that does the ASM stuff, which you can then call from Swift.
It's an annoying workaround, but it should work nonetheless.
You can read more about how to do it [here]
I want to use GtkImageView in my application, but i can't find some examples of code with using gtkimageview anywhere. Where can i see the sample?
Thank you.
There's no GtjImageView in GTK+, I guess you meant GtkIconView. There are two examples for the latter in gtk-demo program that comes with GTK+ itself.