Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

How to port Generic Types to objective-c code?
I have a class:This class is to forge an array and also provides an inheritance to NSObject.When I try to use it in objective-c code. It seems the conversion failed. After experiment a little while , I found after removing all <T>s and replace T with NSObject makes it OK. I've already written lots of classes based on ArrayLike and I'm eagering to use these classes in obj-c. Is there any workaround for this situation?public class ArrayLike<T>: NSObject, SequenceType{ // public typealias SubSequence = Array<T>.SubSequence public typealias Generator = Array<T>.Generator public func generate() -> ArrayLike.Generator { return _impl!.generate() } public func underestimateCount() -> Int { return _impl!.underestimateCount() } public func map<T>(@noescape transform: (ArrayLike.Generator.Element) throws -> T) rethrows -> [T] { return try _impl!.map(transform) } public func filter(includeElement: (ArrayLike.Generator.Element) throws -> Bool) rethrows -> [ArrayLike
0
0
254
Mar ’16
Reply to Apple Configurator 2 - Untrusted Enterprise Developer
We went through a similar problem, currently Apple has no way around this. The device MUST connect to the internet to verify the certificate before it will allow the enterprise app to be used. On top of that it isn't just a one time process. The trust is only established for a certain amount of time (Apple wasn't able to tell us what that exact time is) so if the devices don't connect to the internet after a while this issue will come up again and the app will be rendered useless until the device connects back to the internet. From by understanding the only way around this is to publish the app to the Apple App store and trust is inherited when the app is installed this way. In addition to this the MDM route will automatically establish 'trust' but the certificate still needs to be verified so you will have the same problem.
Mar ’16
Reply to Swift method for Protocol-constrained Type in function arg
You could make an ElementQ subclass that all the Queryable sub-sub-classes inherit from.It seems to me that Swift is heading away from subclassing in favor of protocol composition. If you can go down that road, you could — for example — define an ElementType protocol that contains all the behavior of an Element, apart from Queryable. Then you would specify your function parameter as 'protocol<ElementType,Queryable>' (or whatever that composition syntax is).It feels unnatural for anyone used to class inheritance, but it's probably what you'd need if the intermediate (ElementQ) class doesn't solve the problem.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’16
Reply to Swift method for Protocol-constrained Type in function arg
>> There are specific Element subtypes that are Queryable, and they don't share common parent classes.They do — Element. So there is an actual hierarchy. If you want an OO-inheritance-based solution, then you need each descendant class to inherit from Element or ElementQ, according to whether the descendant should conform to Queryable or not. This has always been the weakness of single-inheritance languages.>> Why should I have to create a protocol that simply describes some of the properties of an Element only because …a. But you were ready to do exactly that in creating a protocol called Queryable.b. But you were ready to do exactly that in creating a base class called Element.Both of those involve extracting parts of a more comprehensive class API into separately defined part.The difference is that these are strategies that you're familiar with, and the full-on composition strategy still seems strange. What happens if you think in terms of eliminating class Element an
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’16
Reply to How to match XPC Service against initiator process? (Network Kernel Extension)
There is, alas, no supported way to do this. I researched this a while back as part of a DTS incident (s. 600,057,819). The system has a ‘responsibility’ mechanism that it uses to track the relationships between processes (you can see the results of this in Activity Monitor) but the API for this is not public (r. 14,860,959).Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’16
Reply to Thread affinity cpu core
I don't think that's possible to link a thread with a specific core with Mac OS X …That’s correct.To test, I've wrote a simple program to validate and it seems impossible to print from which core the thread is executing.That’s also correct.Well, there are ways to work this out but the previous point means it doesn’t do you any good (by the time you look at the result, you might be running on a different CPU).With regards THREAD_AFFINITY_POLICY, that seems pretty well covered in the header comments within <Kernel/thread_policy.h>. To wit: This policy is experimental. This may be used to express affinity relationships between threads in the task. Threads with the same affinity tag will be scheduled to share an L2 cache if possible. That is, affinity tags are a hint to the scheduler for thread placement. The namespace of affinity tags is generally local to one task. However, a child task created after the assignment of affinity tags by its parent will share that namespace. In particular, a family
Mar ’16
Alternative to JSExport?
I am currently working on adding tvOS support to an Objective-C library. I want to enable developers to be able to use the full power of TVML, so I need to find a way to expose the existing ObjC objects into the Javascript Context.I have seen many examples of how to extract the properties and methods you want to expose into a protocol that inherits from the JSExport protocol, but this seems like an awkward solution. I would prefer not to have all of my public classes defined in protocols.Is it possible to dynamically export all properties and methods on all public classes somehow? Perhaps by specifying something in the modulemap file? A colleague suggested that he thought something like this was possible.Thanks!Andrew
0
0
373
Mar ’16
creating segue not working
I start a new project for Mac OS with storyboard. I delete the view controller. I add a vertical split view controller. I control drag from the blue box on the window to the split view controler, which lights up. When I release the mouse a box pops up with 'relationship segue' and 'window content'. When I click on relationship segue the box disappears and nothing happens. I can also do it in the outline on the left with the same results.My eyes are old anb my monitor is dense but if I magnify the box I can see that when the cursor is over content the line is a little darker and when it is over relationship both are the same slightly lighter shade of black. (The guy, it has to be a guy cause a woman would never do it this bad, who designed the interface should be shot. At normal resolution I have to look VERY closely to see any difference when I click these things all over the interface. Would Apple accept an interface like this from a 3rd party? Ahh, I feel a lettle better now.)So i
1
0
511
Apr ’16
Array of Structs, 2D Arrays or ?
Hello, I am an absolute newbie to swift and writing my first iPhone app and I can't figure out how to store my data within my program before I commit it to persistant storage.My program needs to hold lots of structured data entered by the user during program execution before it is committed to persistent storage (on a remote database).I have 3 Structs (since I thought this is the best path to go down), TopLevelStruct, MidLevelStruct and BottomLevelStruct and the latter 2 structs are nested arrays within their immediate predecessor. (note there may be typos in this code...please ignore...I'm just trying to understand how to structure my program). I want the ability to reset the array index in the bottom structure for each instance of the mid structure. See belowstruct bottomLevelStruct { var bottomNum: Int var bottomDescription: String var bottomResult: String}struct MidLevelStruct{ var midNum: Int var midTotal: Int var bottomLevelDetails = [bottomLevelStruct] ()}struct TopLevelStruct{ var date: String var tot
6
0
2.6k
Apr ’16
wkwebview & cookies
Hi there,can I manage cookies programmatically in WKWebView in iOS 9 with override WKWebsiteDataStore or another ones?Can you help me? Also can I create custom storage instead of defaultDataStore? I inherit from WKWebsiteDataStore & create custom class but I'm getting access error in lineconfiguration.websiteDataStore = customStore;WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:frame configuration:configuration];
1
0
1k
Apr ’16
Unique constraints leading to "Dangling reference to an invalid object" on save
I'm introducing Unique Constraints to an existing app, in a new model version.The model has entity Person which has an optional one-to-one relationship with entity Pet. Person's delete rule is cascade, and Pet's inverse relationship delete rule is nullify. There's another entity, Job, which Person also has a to-one relationship. But that deletion rule, and the inverse deletion rule, are both nullify.Person has a personID property which I've made unique.In a main queue context I've got an instance of Person, with ID xxx, that has no Pet set. Let's call that person Charlie. I create a Job as well, and set that as iOS Dev, and assign it to Charlie's job property.Then in a child private queue context, I insert a new Charlie also with ID xxx (the unique constraint) and create a Pet and set it. I don't set a Job. I save the child context with no issue.Immediately after, I attempt to save the Main Queue context. But just before that, I inspect the insertedObjects property of the Main Queue
3
0
2.5k
Apr ’16
Wi-Fi Fundamentals
Wi-Fi is way more complex than you might think. This post attempts to explain some of that complexity, and how that affects the design of your network apps. Note I’m not a Wi-Fi expert. All of the following is the result of hard-won experience gained while investigating various oddball Wi-Fi problems. As a result it’s a vast simplification of how things really work. If you actually get to talk to a Wi-Fi expert, they’ll be happy to explain to you how Wi-Fi is even more complex than what I’ve explain below. Terminology As this post is going to talk about the fundamentals of Wi-Fi, I’m going to use Wi-Fi technical terms. Specifically: STA (station) — This is a Wi-Fi ‘client’ device. AP (access point) — This is the hardware running a single Wi-Fi network. The definition of Wi-Fi network is more complex than you might think, as I’ll explain next. SSID (Service Set Identifier) — This is what most folks think of as the Wi-Fi network. It’s the user-visible network identifier string that you see throughout the system
0
0
8.4k
Apr ’16
Reply to Connecting nib to KeyboardViewController.Swift
It's not clear why you're taking this approach, as the normal approach is much easier.1. Why not use the inherited UIViewController initializer 'initWithNibName:bundle:' to connect your view controller to the NIB? I don't see any value in re-inventing this wheel. However, I don't see anything particularly wrong in doing it your way.2. The link between your programmatically created view controller and the loaded view is …WithOwner(self…). That is, your view controller will be File's Owner in your XIB file, and you should set the class of that pseudo-object to KeyboardViewController.3. If you want to bind from UI elements in the XIB file through the view controller, use File's Owner. Similarly, if you want to connect something (e.g. a delegate) from a UI element to the view controller, use File's Owner as the destination.4. For other purposes, you have to go in the other direction. Set up @IBOutlets in KeyboardViewController, and connect them in the XIB from File's Owner to the relevant UI element. The
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’16
Query relationship hierarchy
I have a fundamental question for Queries in CloudKit.I have a relationship structure set with references where Courses->Holes->Locations. Basically a course owns 18 holes, which each own 4 locations...Is there a way to query to find all locations beneath a given Course without querying by hole? I am trying to reduce the number of queries I have to do to CloudKit to get the information I need.Today I query to get the record for a Course, then one query for all the holes belonging to that course, then I have 18 queries for locations by hole...If I could query all locations in a course, I could reduce my queries from 20 total to 3 total. I know this is possible for a similar structure in coreData. Can't figure it out for Cloudkit.
0
0
131
Apr ’16
How to port Generic Types to objective-c code?
I have a class:This class is to forge an array and also provides an inheritance to NSObject.When I try to use it in objective-c code. It seems the conversion failed. After experiment a little while , I found after removing all <T>s and replace T with NSObject makes it OK. I've already written lots of classes based on ArrayLike and I'm eagering to use these classes in obj-c. Is there any workaround for this situation?public class ArrayLike<T>: NSObject, SequenceType{ // public typealias SubSequence = Array<T>.SubSequence public typealias Generator = Array<T>.Generator public func generate() -> ArrayLike.Generator { return _impl!.generate() } public func underestimateCount() -> Int { return _impl!.underestimateCount() } public func map<T>(@noescape transform: (ArrayLike.Generator.Element) throws -> T) rethrows -> [T] { return try _impl!.map(transform) } public func filter(includeElement: (ArrayLike.Generator.Element) throws -> Bool) rethrows -> [ArrayLike
Replies
0
Boosts
0
Views
254
Activity
Mar ’16
Reply to Apple Configurator 2 - Untrusted Enterprise Developer
We went through a similar problem, currently Apple has no way around this. The device MUST connect to the internet to verify the certificate before it will allow the enterprise app to be used. On top of that it isn't just a one time process. The trust is only established for a certain amount of time (Apple wasn't able to tell us what that exact time is) so if the devices don't connect to the internet after a while this issue will come up again and the app will be rendered useless until the device connects back to the internet. From by understanding the only way around this is to publish the app to the Apple App store and trust is inherited when the app is installed this way. In addition to this the MDM route will automatically establish 'trust' but the certificate still needs to be verified so you will have the same problem.
Replies
Boosts
Views
Activity
Mar ’16
Reply to Swift method for Protocol-constrained Type in function arg
You could make an ElementQ subclass that all the Queryable sub-sub-classes inherit from.It seems to me that Swift is heading away from subclassing in favor of protocol composition. If you can go down that road, you could — for example — define an ElementType protocol that contains all the behavior of an Element, apart from Queryable. Then you would specify your function parameter as 'protocol<ElementType,Queryable>' (or whatever that composition syntax is).It feels unnatural for anyone used to class inheritance, but it's probably what you'd need if the intermediate (ElementQ) class doesn't solve the problem.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’16
Reply to Swift method for Protocol-constrained Type in function arg
>> There are specific Element subtypes that are Queryable, and they don't share common parent classes.They do — Element. So there is an actual hierarchy. If you want an OO-inheritance-based solution, then you need each descendant class to inherit from Element or ElementQ, according to whether the descendant should conform to Queryable or not. This has always been the weakness of single-inheritance languages.>> Why should I have to create a protocol that simply describes some of the properties of an Element only because …a. But you were ready to do exactly that in creating a protocol called Queryable.b. But you were ready to do exactly that in creating a base class called Element.Both of those involve extracting parts of a more comprehensive class API into separately defined part.The difference is that these are strategies that you're familiar with, and the full-on composition strategy still seems strange. What happens if you think in terms of eliminating class Element an
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’16
Reply to How to match XPC Service against initiator process? (Network Kernel Extension)
There is, alas, no supported way to do this. I researched this a while back as part of a DTS incident (s. 600,057,819). The system has a ‘responsibility’ mechanism that it uses to track the relationships between processes (you can see the results of this in Activity Monitor) but the API for this is not public (r. 14,860,959).Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Mar ’16
Reply to Thread affinity cpu core
I don't think that's possible to link a thread with a specific core with Mac OS X …That’s correct.To test, I've wrote a simple program to validate and it seems impossible to print from which core the thread is executing.That’s also correct.Well, there are ways to work this out but the previous point means it doesn’t do you any good (by the time you look at the result, you might be running on a different CPU).With regards THREAD_AFFINITY_POLICY, that seems pretty well covered in the header comments within <Kernel/thread_policy.h>. To wit: This policy is experimental. This may be used to express affinity relationships between threads in the task. Threads with the same affinity tag will be scheduled to share an L2 cache if possible. That is, affinity tags are a hint to the scheduler for thread placement. The namespace of affinity tags is generally local to one task. However, a child task created after the assignment of affinity tags by its parent will share that namespace. In particular, a family
Replies
Boosts
Views
Activity
Mar ’16
Alternative to JSExport?
I am currently working on adding tvOS support to an Objective-C library. I want to enable developers to be able to use the full power of TVML, so I need to find a way to expose the existing ObjC objects into the Javascript Context.I have seen many examples of how to extract the properties and methods you want to expose into a protocol that inherits from the JSExport protocol, but this seems like an awkward solution. I would prefer not to have all of my public classes defined in protocols.Is it possible to dynamically export all properties and methods on all public classes somehow? Perhaps by specifying something in the modulemap file? A colleague suggested that he thought something like this was possible.Thanks!Andrew
Replies
0
Boosts
0
Views
373
Activity
Mar ’16
creating segue not working
I start a new project for Mac OS with storyboard. I delete the view controller. I add a vertical split view controller. I control drag from the blue box on the window to the split view controler, which lights up. When I release the mouse a box pops up with 'relationship segue' and 'window content'. When I click on relationship segue the box disappears and nothing happens. I can also do it in the outline on the left with the same results.My eyes are old anb my monitor is dense but if I magnify the box I can see that when the cursor is over content the line is a little darker and when it is over relationship both are the same slightly lighter shade of black. (The guy, it has to be a guy cause a woman would never do it this bad, who designed the interface should be shot. At normal resolution I have to look VERY closely to see any difference when I click these things all over the interface. Would Apple accept an interface like this from a 3rd party? Ahh, I feel a lettle better now.)So i
Replies
1
Boosts
0
Views
511
Activity
Apr ’16
Array of Structs, 2D Arrays or ?
Hello, I am an absolute newbie to swift and writing my first iPhone app and I can't figure out how to store my data within my program before I commit it to persistant storage.My program needs to hold lots of structured data entered by the user during program execution before it is committed to persistent storage (on a remote database).I have 3 Structs (since I thought this is the best path to go down), TopLevelStruct, MidLevelStruct and BottomLevelStruct and the latter 2 structs are nested arrays within their immediate predecessor. (note there may be typos in this code...please ignore...I'm just trying to understand how to structure my program). I want the ability to reset the array index in the bottom structure for each instance of the mid structure. See belowstruct bottomLevelStruct { var bottomNum: Int var bottomDescription: String var bottomResult: String}struct MidLevelStruct{ var midNum: Int var midTotal: Int var bottomLevelDetails = [bottomLevelStruct] ()}struct TopLevelStruct{ var date: String var tot
Replies
6
Boosts
0
Views
2.6k
Activity
Apr ’16
wkwebview & cookies
Hi there,can I manage cookies programmatically in WKWebView in iOS 9 with override WKWebsiteDataStore or another ones?Can you help me? Also can I create custom storage instead of defaultDataStore? I inherit from WKWebsiteDataStore & create custom class but I'm getting access error in lineconfiguration.websiteDataStore = customStore;WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:frame configuration:configuration];
Replies
1
Boosts
0
Views
1k
Activity
Apr ’16
command failed due to signal:Segmentation fault 11
when i convert my project to swift 2.2 from swift 2.1i get command failed due to signal:Segmentation fault 11 error every class inherit from objective-c class such as class myClass : NSOjbect have getten this error
Replies
4
Boosts
0
Views
4.9k
Activity
Apr ’16
Unique constraints leading to "Dangling reference to an invalid object" on save
I'm introducing Unique Constraints to an existing app, in a new model version.The model has entity Person which has an optional one-to-one relationship with entity Pet. Person's delete rule is cascade, and Pet's inverse relationship delete rule is nullify. There's another entity, Job, which Person also has a to-one relationship. But that deletion rule, and the inverse deletion rule, are both nullify.Person has a personID property which I've made unique.In a main queue context I've got an instance of Person, with ID xxx, that has no Pet set. Let's call that person Charlie. I create a Job as well, and set that as iOS Dev, and assign it to Charlie's job property.Then in a child private queue context, I insert a new Charlie also with ID xxx (the unique constraint) and create a Pet and set it. I don't set a Job. I save the child context with no issue.Immediately after, I attempt to save the Main Queue context. But just before that, I inspect the insertedObjects property of the Main Queue
Replies
3
Boosts
0
Views
2.5k
Activity
Apr ’16
Wi-Fi Fundamentals
Wi-Fi is way more complex than you might think. This post attempts to explain some of that complexity, and how that affects the design of your network apps. Note I’m not a Wi-Fi expert. All of the following is the result of hard-won experience gained while investigating various oddball Wi-Fi problems. As a result it’s a vast simplification of how things really work. If you actually get to talk to a Wi-Fi expert, they’ll be happy to explain to you how Wi-Fi is even more complex than what I’ve explain below. Terminology As this post is going to talk about the fundamentals of Wi-Fi, I’m going to use Wi-Fi technical terms. Specifically: STA (station) — This is a Wi-Fi ‘client’ device. AP (access point) — This is the hardware running a single Wi-Fi network. The definition of Wi-Fi network is more complex than you might think, as I’ll explain next. SSID (Service Set Identifier) — This is what most folks think of as the Wi-Fi network. It’s the user-visible network identifier string that you see throughout the system
Replies
0
Boosts
0
Views
8.4k
Activity
Apr ’16
Reply to Connecting nib to KeyboardViewController.Swift
It's not clear why you're taking this approach, as the normal approach is much easier.1. Why not use the inherited UIViewController initializer 'initWithNibName:bundle:' to connect your view controller to the NIB? I don't see any value in re-inventing this wheel. However, I don't see anything particularly wrong in doing it your way.2. The link between your programmatically created view controller and the loaded view is …WithOwner(self…). That is, your view controller will be File's Owner in your XIB file, and you should set the class of that pseudo-object to KeyboardViewController.3. If you want to bind from UI elements in the XIB file through the view controller, use File's Owner. Similarly, if you want to connect something (e.g. a delegate) from a UI element to the view controller, use File's Owner as the destination.4. For other purposes, you have to go in the other direction. Set up @IBOutlets in KeyboardViewController, and connect them in the XIB from File's Owner to the relevant UI element. The
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Apr ’16
Query relationship hierarchy
I have a fundamental question for Queries in CloudKit.I have a relationship structure set with references where Courses->Holes->Locations. Basically a course owns 18 holes, which each own 4 locations...Is there a way to query to find all locations beneath a given Course without querying by hole? I am trying to reduce the number of queries I have to do to CloudKit to get the information I need.Today I query to get the record for a Course, then one query for all the holes belonging to that course, then I have 18 queries for locations by hole...If I could query all locations in a course, I could reduce my queries from 20 total to 3 total. I know this is possible for a similar structure in coreData. Can't figure it out for Cloudkit.
Replies
0
Boosts
0
Views
131
Activity
Apr ’16