Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to Turn based skeleton project
Thanks mhatzitaskos,A very good initiative!I've taken a quick look. One initial comment is that I don't use a singleton to implement the listener functions. Instead I register a listener on the GKLocalPlayer when I enter different scenes. Each SKScene inherit GKLocalPlayerListener and can thus have specific listener methods, and some scenes can just ignore some events. Any comments on that?
Topic: Graphics & Games SubTopic: GameKit Tags:
Jan ’16
Reply to What is the behavior when there are multiple apps implementing NETunnelProvider class of APIs
I dont understand this statement:>>If you’re implementing Per-App VPN, you’ll wantAppProxy instead of PacketTunnel. The documentation states NETunnelProvider has routingMethod property DestinationIP or SourceApplication.Since NEPacketTunnelProvider inherits from NETunnelProvider, the routing method should be SourceApplication when per-app-vpn profile is installed. Please help me understand why per-app-vpn does not work with NEPacketTunnelProvider
Jan ’16
Reply to How to list Application hierarchy like Activity Monitor?
How can I learn that remoteservice (pid 22043) was created by System Preferences (pid 22033)?I researched this a while back as part of a DTS incident. The system has a ‘responsibility’ mechanism that it uses to track these relationships. The API for this is not public (r. 14860959).Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Jan ’16
nepackettunnelprovider and per-app-vpn
In thread https://forums.developer.apple.com/thread/17019 there is statement>>If you’re implementing Per-App VPN, you’ll want AppProxy instead of PacketTunnel.The documentation states NETunnelProvider has routingMethod property DestinationIP or SourceApplication.Since NEPacketTunnelProvider inherits from NETunnelProvider, the routing method should be SourceApplication when per-app-vpn profile is installed. Please help me understand why per-app-vpn will not work with NEPacketTunnelProviderI am using nepackettunnelprovider for my vpn extension and I want to be sure that per-app-vpn works with this.Also, is checking routingMethod property value at runtime the best way to know if the vpn extn is indeed using per app vpn ?
5
0
1.7k
Jan ’16
Does it possible to override kext's methods by other kext
I'm tring to implement my own kext for Apple keyboards (USB with numpad and bluetooth) by rewriting kext for Logitech device described in this post, source code for it is stored on GitHub. I changed IOKitPersonalities settings in plist: ProductID 545, VendorID 1452 (my Apple USB keyboard). Also I added some IOLog calls in cpp code. I turn off SIP, enable kext debug mode. Kext loads and starts fine when keyboard plugin, but my custom dispatchKeyboardEvent method is called only for button 'Eject'.08.01.16 23:21:44,000 kernel[0]: LogitechWirelessPresenterDriver start 08.01.16 23:21:44,000 kernel[0]: LogitechWirelessPresenterDriver start with IOHIDInterface, vendor 1452, device 545I have device tree in IORegistryExplorer. As you can see, keyboard has two drivers at the same time: AppleHIDKeyboardEventDriver & LogitechWirelessPresenterDriver. Does is possible on 10.11 to intercept all other key pressing by this way?I think what my driver 'inherit' from IOHIDConsumer and this is a cause of small list o
0
0
901
Jan ’16
Reply to Can I pass a function the name of a field to act on?
So, you want to do this?var fieldName = backgroundColor mytextfield.setValue(value: UIColor.lightGrayColor(), forKey: fieldName)I'm pretty sure you can do it like that, but only because UITextFields are Obj-C classes and inherit from NSObject. It's not a part of the Swift language. Also, it'll crash if mytextfield doesn't actually have a property with the passed-in name.Incidentally, doing it by passing property names around is quite slow, if that matters for your app.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
Reply to NSCollectionViewDataSource method return different result in Objc and Swift ?
First of all, please remember my style of coding may not be the best recommended and you can find many points to improve.you prefix classes with @objc When should / need I use @objc ?The classes in Apple's sample codes may be instantiated through nib, so when translating, it's safe to have an Objective-C compatible name included in .xib/.storyboard. As you see, manipulating existing nib files is not an easy thing. Not all @objc annotations are necessary. I rarely use @objc annotations in my original app.Simply saying, it makes translating easier.Many of your var are declared private. Is this for memory management only or does it have other effect ?My main intension to make things `private` is giving a better opportunity of optimizing to compiler. Swift has only properties, no explicit ivars, but `private` properties can easily optimized and Swift generates the best optimized code which has no loss accessing ivars through setters/getters.enum is defined as @objc, as well as its instances ;I did not do so and h
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
Load pure Swift bundle - no success
Hello,I do not succeed to load a bundle in a pure swift project. I tried a lot but I either get linker errors or build succeeds but I can not get an instance of principalClass as the typecast does not work:This is my principalClass. I tried with/without NSObject inheritance and with/without @objc:@objc public final class BDomProjectDebugWindowsBundle: NSObject { lazy var debugWindowController: DebugWindowController = { return DebugWindowController(windowNibName: DebugWindowController) }() lazy var inspectWindowController: InspectWindowController = { return InspectWindowController(windowNibName: InspectWindowController) }() public override init() { super.init() }}I tried loading like this:import BDomProjectDebugWindows //name of the bundle lazy var debugWindowsBundleObject: BDomProjectDebugWindowsBundle? = { guard let bundle = NSBundle(URL: url) else {return nil} //url is OK and bundle is loaded let meta = bundle.principalClass as! BDomProjectDebugWindowsBundle.Type //THIS CAST DOES NOT WORK (meta is
1
0
902
Jan ’16
iOS + AVFoundation. Different photo brightness with the same manual exposure settings
I use AVFoundation to take photos. Trouble is that even with constant settings of exposure duration, ISO and white balance I get photos with different brightness. Torch, flash and all possible stabilizations are disabled.This issue is also presented in standard Apple app introducing working with camera: https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112This is the video I filmed via this app containing no changes except setting manual exposure during session initialization:https://www.youtube.com/watch?v=g9NOWGVeftINotice the sudden brightening what should not be if exposure settings of digital camera are constant (no, it is not moment when exposure settings have been set and completion handler has been called; settings are already set).The brightening happens not always but anyway there can be significant brightness difference if I move camera away and aim to object again. But if I make series of photo without moving camera the brightnesses are sa
4
0
2.4k
Jan ’16
Subclassing a class that has convenience initializers.
Hi all.Note: I am using the latest version of Xcode and Swift to date (official releases.)Here is a scenario. ClassA (a framework class) defines a convenience initializer. Subclass ClassB (my custom class) defines a new optional property and a designated initializer for it. (As per the Swift Programming Language 2.1, defining an initializer for the subclass means that none of the superclass's initializers will be inherited.)Now, what I want to be able to do is create an instance of ClassB using the convenience initializer from ClassA. Is this possible? If so, how?I cannot override the convenience initializer because, being a framework class, I don't know what it does. And I can't call a convenience initializer from a superclass as per the rules of the language.class BaseClass { var property1 = 0 init(property1: Int) { self.property1 = property1 } convenience init(value1: Int, value2: Int) { // Super secret formula hidden in a frame work that I don't have access to. self.init(property1: value1 + value
3
0
5.2k
Jan ’16
Reply to Subclassing a class that has convenience initializers.
If you override all of the superclass designated initializers, you'll inherit the superclass convenience initializers. (See Swift docs, Initialization -> Automatic Initializer Inheritance -> Rule 2.) I think in this case that means you can define an init(property1:) that just calls through to super and you should able to use init(value1:value2) for subclass initialization.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
why don't inherited iVars / instance variables show in the debugger?
I have sub-classed NSError to CDError. NSError shows what amounts to a partial list of instance variables in the debugger (suffices) but what is difficult is that my subclass instance of CDError shows none of the instance variables of the subclass.Something I am doing wrong? Do I have to define something special in CDError to get the debugger to show me all the instance variables available to it? Am I stuck creating custom expression like theError->_code in the debugger?I started to put an instance variable in my subclass so I could set it to 'self' to see the values held in NSError. That is the error instance variable (nil) shown in theError. Decided to post here before I went any farther so don't be side tracked by that iVar pls. I hate to think that every subclass I create I will be putting iVars in for each class below it to see the contents of the internals of the object without creating custom debugger expressions for each one...<img src=https://www.evernote.com/l/ACBPTDBHM1tIUoVIKry9EmrAWgXaoqBHC
0
0
255
Jan ’16
Reply to Build IOS and Cocoa version of module in same project?
Doing what you want across *workspace* boundaries is a pain, and if you have two open projects — one for the app, one for the frameworks — then you have two workspaces. That's because if you don't create any workspaces explicitly, Xcode embeds one in the project for you.(This can be a little confusing. If you create a workspace manually, the workspace conceptually contains the project(s) inside it. If you just have a project, the project contains the workspace. But the relationship is conceptually the same in both cases. A workspace contains one or more projects, whether the workspace is implicit or explicit.)So, the easiest approach is to dump all of your targets (app and framework) into the same project. If you don't want to do that (for example, if the frameworks are in a different source control repository), then add the framework *project* into the app project, or create a workspace containing both projects.(Either way, you'll end up with both projects in the same workspace, whether it looks lik
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
Reply to Restricting a protocol's associated type to protocols
ObjectHub's solution seems like the way to go, but this is an interesting question for other reasons, too.Even if there were an AnyProtocol constraint you could apply, I don't think it would help. Consider:class Foo {} protocol Bar { typealias T: Foo func bar<U: T>(u: U) // Err: Inheritance from non-protocol, non-class type Self.T }The compiler does enforce the kind-of Foo constraint, but only by checking it when a specific type declares conformity to P. When parsing the rest of the protocol, it doesn't seem to make the connection that Ts will always be Foos. The typealias is always going to be treated like an unkown type from the perspective of the protocol itself.(In this particular case, you could just declare u as a T, since that would accept subclasses of T and thereby achieve the same result. But syntactically, the form shown ought to be valid.)
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
Reply to Turn based skeleton project
Thanks mhatzitaskos,A very good initiative!I've taken a quick look. One initial comment is that I don't use a singleton to implement the listener functions. Instead I register a listener on the GKLocalPlayer when I enter different scenes. Each SKScene inherit GKLocalPlayerListener and can thus have specific listener methods, and some scenes can just ignore some events. Any comments on that?
Topic: Graphics & Games SubTopic: GameKit Tags:
Replies
Boosts
Views
Activity
Jan ’16
Reply to What is the behavior when there are multiple apps implementing NETunnelProvider class of APIs
I dont understand this statement:>>If you’re implementing Per-App VPN, you’ll wantAppProxy instead of PacketTunnel. The documentation states NETunnelProvider has routingMethod property DestinationIP or SourceApplication.Since NEPacketTunnelProvider inherits from NETunnelProvider, the routing method should be SourceApplication when per-app-vpn profile is installed. Please help me understand why per-app-vpn does not work with NEPacketTunnelProvider
Replies
Boosts
Views
Activity
Jan ’16
Reply to How to list Application hierarchy like Activity Monitor?
How can I learn that remoteservice (pid 22043) was created by System Preferences (pid 22033)?I researched this a while back as part of a DTS incident. The system has a ‘responsibility’ mechanism that it uses to track these relationships. The API for this is not public (r. 14860959).Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Replies
Boosts
Views
Activity
Jan ’16
nepackettunnelprovider and per-app-vpn
In thread https://forums.developer.apple.com/thread/17019 there is statement>>If you’re implementing Per-App VPN, you’ll want AppProxy instead of PacketTunnel.The documentation states NETunnelProvider has routingMethod property DestinationIP or SourceApplication.Since NEPacketTunnelProvider inherits from NETunnelProvider, the routing method should be SourceApplication when per-app-vpn profile is installed. Please help me understand why per-app-vpn will not work with NEPacketTunnelProviderI am using nepackettunnelprovider for my vpn extension and I want to be sure that per-app-vpn works with this.Also, is checking routingMethod property value at runtime the best way to know if the vpn extn is indeed using per app vpn ?
Replies
5
Boosts
0
Views
1.7k
Activity
Jan ’16
Does it possible to override kext's methods by other kext
I'm tring to implement my own kext for Apple keyboards (USB with numpad and bluetooth) by rewriting kext for Logitech device described in this post, source code for it is stored on GitHub. I changed IOKitPersonalities settings in plist: ProductID 545, VendorID 1452 (my Apple USB keyboard). Also I added some IOLog calls in cpp code. I turn off SIP, enable kext debug mode. Kext loads and starts fine when keyboard plugin, but my custom dispatchKeyboardEvent method is called only for button 'Eject'.08.01.16 23:21:44,000 kernel[0]: LogitechWirelessPresenterDriver start 08.01.16 23:21:44,000 kernel[0]: LogitechWirelessPresenterDriver start with IOHIDInterface, vendor 1452, device 545I have device tree in IORegistryExplorer. As you can see, keyboard has two drivers at the same time: AppleHIDKeyboardEventDriver & LogitechWirelessPresenterDriver. Does is possible on 10.11 to intercept all other key pressing by this way?I think what my driver 'inherit' from IOHIDConsumer and this is a cause of small list o
Replies
0
Boosts
0
Views
901
Activity
Jan ’16
Reply to Can I pass a function the name of a field to act on?
So, you want to do this?var fieldName = backgroundColor mytextfield.setValue(value: UIColor.lightGrayColor(), forKey: fieldName)I'm pretty sure you can do it like that, but only because UITextFields are Obj-C classes and inherit from NSObject. It's not a part of the Swift language. Also, it'll crash if mytextfield doesn't actually have a property with the passed-in name.Incidentally, doing it by passing property names around is quite slow, if that matters for your app.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
Reply to NSCollectionViewDataSource method return different result in Objc and Swift ?
First of all, please remember my style of coding may not be the best recommended and you can find many points to improve.you prefix classes with @objc When should / need I use @objc ?The classes in Apple's sample codes may be instantiated through nib, so when translating, it's safe to have an Objective-C compatible name included in .xib/.storyboard. As you see, manipulating existing nib files is not an easy thing. Not all @objc annotations are necessary. I rarely use @objc annotations in my original app.Simply saying, it makes translating easier.Many of your var are declared private. Is this for memory management only or does it have other effect ?My main intension to make things `private` is giving a better opportunity of optimizing to compiler. Swift has only properties, no explicit ivars, but `private` properties can easily optimized and Swift generates the best optimized code which has no loss accessing ivars through setters/getters.enum is defined as @objc, as well as its instances ;I did not do so and h
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
Load pure Swift bundle - no success
Hello,I do not succeed to load a bundle in a pure swift project. I tried a lot but I either get linker errors or build succeeds but I can not get an instance of principalClass as the typecast does not work:This is my principalClass. I tried with/without NSObject inheritance and with/without @objc:@objc public final class BDomProjectDebugWindowsBundle: NSObject { lazy var debugWindowController: DebugWindowController = { return DebugWindowController(windowNibName: DebugWindowController) }() lazy var inspectWindowController: InspectWindowController = { return InspectWindowController(windowNibName: InspectWindowController) }() public override init() { super.init() }}I tried loading like this:import BDomProjectDebugWindows //name of the bundle lazy var debugWindowsBundleObject: BDomProjectDebugWindowsBundle? = { guard let bundle = NSBundle(URL: url) else {return nil} //url is OK and bundle is loaded let meta = bundle.principalClass as! BDomProjectDebugWindowsBundle.Type //THIS CAST DOES NOT WORK (meta is
Replies
1
Boosts
0
Views
902
Activity
Jan ’16
iOS + AVFoundation. Different photo brightness with the same manual exposure settings
I use AVFoundation to take photos. Trouble is that even with constant settings of exposure duration, ISO and white balance I get photos with different brightness. Torch, flash and all possible stabilizations are disabled.This issue is also presented in standard Apple app introducing working with camera: https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010112This is the video I filmed via this app containing no changes except setting manual exposure during session initialization:https://www.youtube.com/watch?v=g9NOWGVeftINotice the sudden brightening what should not be if exposure settings of digital camera are constant (no, it is not moment when exposure settings have been set and completion handler has been called; settings are already set).The brightening happens not always but anyway there can be significant brightness difference if I move camera away and aim to object again. But if I make series of photo without moving camera the brightnesses are sa
Replies
4
Boosts
0
Views
2.4k
Activity
Jan ’16
Subclassing a class that has convenience initializers.
Hi all.Note: I am using the latest version of Xcode and Swift to date (official releases.)Here is a scenario. ClassA (a framework class) defines a convenience initializer. Subclass ClassB (my custom class) defines a new optional property and a designated initializer for it. (As per the Swift Programming Language 2.1, defining an initializer for the subclass means that none of the superclass's initializers will be inherited.)Now, what I want to be able to do is create an instance of ClassB using the convenience initializer from ClassA. Is this possible? If so, how?I cannot override the convenience initializer because, being a framework class, I don't know what it does. And I can't call a convenience initializer from a superclass as per the rules of the language.class BaseClass { var property1 = 0 init(property1: Int) { self.property1 = property1 } convenience init(value1: Int, value2: Int) { // Super secret formula hidden in a frame work that I don't have access to. self.init(property1: value1 + value
Replies
3
Boosts
0
Views
5.2k
Activity
Jan ’16
Reply to Subclassing a class that has convenience initializers.
If you override all of the superclass designated initializers, you'll inherit the superclass convenience initializers. (See Swift docs, Initialization -> Automatic Initializer Inheritance -> Rule 2.) I think in this case that means you can define an init(property1:) that just calls through to super and you should able to use init(value1:value2) for subclass initialization.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
why don't inherited iVars / instance variables show in the debugger?
I have sub-classed NSError to CDError. NSError shows what amounts to a partial list of instance variables in the debugger (suffices) but what is difficult is that my subclass instance of CDError shows none of the instance variables of the subclass.Something I am doing wrong? Do I have to define something special in CDError to get the debugger to show me all the instance variables available to it? Am I stuck creating custom expression like theError->_code in the debugger?I started to put an instance variable in my subclass so I could set it to 'self' to see the values held in NSError. That is the error instance variable (nil) shown in theError. Decided to post here before I went any farther so don't be side tracked by that iVar pls. I hate to think that every subclass I create I will be putting iVars in for each class below it to see the contents of the internals of the object without creating custom debugger expressions for each one...<img src=https://www.evernote.com/l/ACBPTDBHM1tIUoVIKry9EmrAWgXaoqBHC
Replies
0
Boosts
0
Views
255
Activity
Jan ’16
Reply to Build IOS and Cocoa version of module in same project?
Doing what you want across *workspace* boundaries is a pain, and if you have two open projects — one for the app, one for the frameworks — then you have two workspaces. That's because if you don't create any workspaces explicitly, Xcode embeds one in the project for you.(This can be a little confusing. If you create a workspace manually, the workspace conceptually contains the project(s) inside it. If you just have a project, the project contains the workspace. But the relationship is conceptually the same in both cases. A workspace contains one or more projects, whether the workspace is implicit or explicit.)So, the easiest approach is to dump all of your targets (app and framework) into the same project. If you don't want to do that (for example, if the frameworks are in a different source control repository), then add the framework *project* into the app project, or create a workspace containing both projects.(Either way, you'll end up with both projects in the same workspace, whether it looks lik
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
Reply to Remote app - get it talking to my app?
Actually, I was able to get it to work. You just need to implement the pressesBegan, pressesEnded, pressesCancelled routines of your view (at least, in an opengl app where your view inherits from UIView, it works.)
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jan ’16
Reply to Restricting a protocol's associated type to protocols
ObjectHub's solution seems like the way to go, but this is an interesting question for other reasons, too.Even if there were an AnyProtocol constraint you could apply, I don't think it would help. Consider:class Foo {} protocol Bar { typealias T: Foo func bar<U: T>(u: U) // Err: Inheritance from non-protocol, non-class type Self.T }The compiler does enforce the kind-of Foo constraint, but only by checking it when a specific type declares conformity to P. When parsing the rest of the protocol, it doesn't seem to make the connection that Ts will always be Foos. The typealias is always going to be treated like an unkown type from the perspective of the protocol itself.(In this particular case, you could just declare u as a T, since that would accept subclasses of T and thereby achieve the same result. But syntactically, the form shown ought to be valid.)
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16