Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to Best Way to Migrate Core Data iCloud App to CloudKit
Yes, you are looking for:- (NSPersistentStore *)migratePersistentStore:(NSPersistentStore *)store toURL:(NSURL *)URL options:(NSDictionary *)options withType:(NSString *)storeType error:(NSError **)errorMake sure that you don't have the ubiquity options in the options dictionary when you make the call, otherwise we'll attempt to ubiquitize the migrated store.Be aware that certain features of you managed object model may be incompatible with CloudKit (required relationships for example), your mechanism of syncing changes with CloudKit should take this in to account when it builds your CKRecord graph.
Sep ’16
Subclass inherit from class not able to access properties
I have defined the following class and subclass:import Foundation class Node { var key : String private weak var parent: Node? private var children: [Node] = [] init(key : String) { self.key = key } func addChildNode(child: Node) { children.append(child) child.parent = self } func rootNode() -> Node { var node = self while node.parent != nil { node = node.parent! } return node } } class SubNode : Node { var time : [Double] = [] }When using the subclass and the method rootNode inherited, this returns the class Node and not the subclass SubNode. Therefore, I can not access the time property. One option is of course to cast explicitily the outcome of the rootNode as SubNode. But this is not very elegant. Any other idea?var a = SubNode(key: a) a.time = [11,2,3] var b = SubNode(key: b) var c = SubNode(key: c) a.addChildNode(b) b.addChildNode(c) c.rootNode() // c.rootNode can not access time unles casted as SubNode
3
0
3.6k
Sep ’16
Reply to Subclass inherit from class not able to access properties
Swift doesn't have covariance for return types (yet?), and that's what would let you override rootNode in a subclass to return a SubNode. That aside, the problem is, of course, that an instance of SubNode can't be sure that it's returning a SubNode root, because it doesn't control the type of the stored properties that have nodes for values.You can work around the problem, clumsily, by giving SubNode a subRootNode property, if you don't want to force clients of the class to do a cast.A better approach, in the Swift philosopy, is to not use class inheritance at all. Instead, you'd declare a NodeProtocol that defines the shared behavior of all nodes, and put the base class behavior in a protocol extension that implements default behavior. You can still have a Node base class if you want, but ideally you don't need it, and your (no-longer-sub-)classes would just implement their versions of the protocol behavior.This is known as protocol oriented programming, and you should find a lot of discussion of it
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’16
Reply to Cannot invoke 'dataTask' with an argument list of type...
That would make very much Android programming... frankly I do not see so much the need to create so many layers in an object oriented environment but rather have in my full view the full piece of code I am working with. But of course this is a matter of taste. Somone like it horizontal, some othe ones like it vertical :-) It mins me of the bias, also being enforced in the WWDC, towards the have relationoship, oppsotie to the is one (property verus inheritance). OO theory has weel gaounded criteria to decide the relationships bwtween classes o to better model reality and I hold any attempt to steer somewhere for this make for not so easily maintanable code. But again this is a matter of taste.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’16
Reply to CloudKit reference subscription requires CKReferenceActionDeleteSelf reference?
In WWDC 2016 they said there is a parent property in CKRecord to use in order to establish hierarchical dependencies, so my question is: what about CKReference? and how to use, if the purpose is not a parent-child relationship... Anywhay, CKReference are useful to just link two records and setting the action to .deleteSelf or .none is just a part of that link.
Sep ’16
Upload to iTunes Connect error: Your app contains non-public API usage
I created a sticker pack with no code. I'm able to export to a developer .ipa file. When I try and upload using Application Loader I get an error:Your app contains non-public API usage...The app contains or inherits from non public classes in Payload/XXX/Plugins/StickerPackExtension.appex/StickerPackExtension:_MSStickerPackCollectionViewDataSourceI can't figure this out because I haven't added any frameworks or any code, its just images. Is this due to the fact that its a development build? Or are we not able to upload yet from sticker builds from XCode 8 beta 6?
6
0
1.3k
Sep ’16
Paged Watch Interface and WKCrownSequencer focus
I'm having a problem with using the CrownSequencer on a page-based watch app, where I can't find the right way to get the WKCrownSequencer to be active on the first page right after launching. The app's interface storyboard has two WKInterfaceController objects connected with a nextPage relationship segue. Here's the summary of events that happen at app launch:-awakeWithContext: is called on page 1-awakeWithContext: is called on page 2-willActivate is called on page 1-willActivate is called on page 2-didDeactivate: is called on page 2 (because page 1 is the visible page)The problem -- I'd like to access the WKCrownSequencer on both pages, but where do I put the call to -focus? If I put it in -awakeWithContext: or -willActivate, then when first launching, page 1 is visible, but the crown is always active on page 2, since these methods are called on all pages in order. Even if I called -resignFocus in -didDeactivate of page 2, that doesn't give the focus back to page 1. With the page based interface, t
1
0
493
Sep ’16
Reply to Swift3 ignoring Objective-C properties?
I sympathize. Stupid question: if you're converting code, why are you keeping Obj-C source? Could you rewrite the AKContext class hierarchy in Swift instead? I suspect your problem is some conflict across the super-/sub-class relationships. Rewriting in Swift might reveal a problem that slides under the radar in Obj-C source.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’16
Reply to Optional colon in ternary operator
Clearly you can write your code any way you’re comfortable with but the C idiom, which Swift inherits, is that:if statements are used when you want a statement?: is a shortcut to avoid temporaries when you want a valueI realise that the example in your first post is just an example, but that specific case would be much better served by filter(isIncluded:). For example, to find the even numbers in an array. let a = [1, 2, 3, 4] let b = a.filter { (i: Int) -> Bool in return i % 2 == 0 } print(b) // prints [2, 4]If you really want to get concise you can crunch this down quite dramatically.let b = a.filter { $0 % 2 == 0 }Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’16
Reply to Invalid Bundle error from iTC, cannot submit app - because 4 swift dylibs fail to embed
Also, I cannot export to an ADHOC build from xcode for the same reason. It fails on the comiling from bitcode step.Here are some snippets, anyone know how to fix these? I checked that my runtime search paths include executable_path/frameworks, loader_path/frameworks, inherited etc... all of those were already there Debug: Search Path: ['/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin', '/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/usr/lib', '/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks'] error: libswiftCore.dylib not found in dylib search path2016-09-14 15:33:40 +0000 /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1 2016-09-14 15:33:40 +0000 ipatool JSON: { alerts = ( { code = 2554; description = Configuration issue: platform AppleTVSimulator.platform doesn't have any non-sim
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’16
Reply to Sending an object with MSMessage
I agree the documentation is not super clear and the Ice Cream Builder code not compiling does not help.So far, I have been able to create a new message by executing the code below in a UIViewController which inherits from MSMessagesAppViewController. I have yet to figure out a way to get the activeConversation thread to insert into, as calling this on the controller returns nil. In regards to your other questions, you do not create a send button, this exists in iMessage. Creating a message simply places it into the input field for the user to send. This makes sense, as some developers would have surely abused auto-sending capability. As far as passing your game-variables and state, the URL would be a great way to do it. You could add the key-value pairs into the URL as necessary and parse on the recipents end. MSConversation *conversation = [MSConversation new]; if (conversation) { MSMessageTemplateLayout *layout = [[MSMessageTemplateLayout alloc] init]; layout.caption = @Caption; layout.subcaption
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’16
Flagged as using Private API
When I submitted an update to my app yesterday, I got a rejection saying I was using a private API called `addAction:` (apple app ID 643351983). A thorough scrub of my code shows only one place any `addAction:` is defined / called in my (or third party) code: an autogenerated method by Core Data for one of my NSManagedObject subclasses, which has a relationship called Actions.Clearly this private API search is text-based.This generated code has been in my app since 2013, largely untouched. App review approved my app, but requested I change the method name in order to prevent future flagging. Unfortunantly this is part of my data model layer and I really don't want to change it. It's not a trivial change as I do a lot of serialization and backing up of data base on the names of my entity properties. I'd be happy to change if I was using a private API, but I'm not, and App Review simply wants me to do all this extra work this to avoid future confusion.Something changed with the private API checks aroun
0
0
754
Sep ’16
GKScene and SKNode.entity
I've been updating a SpriteKit/GameplayKit project for Xcode 8 and the new Scene Editor which allows adding Entity-Component information to a scene. I've been to move my entity code into the scene, but I'm having trouble accessing the entity from the corresponding node. As per Apple's documentation:Any SpriteKit node in the scene to which you’ve attached an entity or components automatically has a GKSKNodeComponent object to manage the relationship between the node and the the GKEntity object it represents.andAdding a GKSKNodeComponent object to an entity automatically updates the entity property of the component’s SpriteKit node (an SKNode object) to point to that entity.The new code I have to load the scene is basically as follows:guard let newTowerScene = GKScene(fileNamed: TowerScene), let rootScene = newTowerScene.rootNode as? SKScene else { return } self.view?.presentScene(rootScene, transition: SKTransition.push(with: .up, duration: 1.75))Accessing the GKScene object returns an array of proper
2
0
1.7k
Sep ’16
IAP of Prepaid or "top up" mobile data or voice
Hello,If a mobile phone operator wanted to create an App to allow purchase of prepaid or top up data or voice, it could be implemented a number of ways1. The App could request a purchase of prepaid or top up data or voice from the mobile phone operator and that would be billed to the customer's credit card held with at the mobile phone operator, not via IAP2. The App could request a purchase of top up data or voice from the mobile phone operator and that would be billed to the customer's existing post paid account with the mobile phone operator, not via IAP3. The App could use IAP as a mehcnaims for charging prepaid or top up data or voiceDoes Apple allow 1 and 2, purchase of a service, not using IAP, whcih is not delivered In App, where the customer has an existing relationship with the service provider, In fact the purchase may be for a differnet phone to the one that the customer is using the App on.Does Apple charge 30% of 3 ?Thanksjohn
1
0
496
Sep ’16
Reply to Best Way to Migrate Core Data iCloud App to CloudKit
Yes, you are looking for:- (NSPersistentStore *)migratePersistentStore:(NSPersistentStore *)store toURL:(NSURL *)URL options:(NSDictionary *)options withType:(NSString *)storeType error:(NSError **)errorMake sure that you don't have the ubiquity options in the options dictionary when you make the call, otherwise we'll attempt to ubiquitize the migrated store.Be aware that certain features of you managed object model may be incompatible with CloudKit (required relationships for example), your mechanism of syncing changes with CloudKit should take this in to account when it builds your CKRecord graph.
Replies
Boosts
Views
Activity
Sep ’16
Subclass inherit from class not able to access properties
I have defined the following class and subclass:import Foundation class Node { var key : String private weak var parent: Node? private var children: [Node] = [] init(key : String) { self.key = key } func addChildNode(child: Node) { children.append(child) child.parent = self } func rootNode() -> Node { var node = self while node.parent != nil { node = node.parent! } return node } } class SubNode : Node { var time : [Double] = [] }When using the subclass and the method rootNode inherited, this returns the class Node and not the subclass SubNode. Therefore, I can not access the time property. One option is of course to cast explicitily the outcome of the rootNode as SubNode. But this is not very elegant. Any other idea?var a = SubNode(key: a) a.time = [11,2,3] var b = SubNode(key: b) var c = SubNode(key: c) a.addChildNode(b) b.addChildNode(c) c.rootNode() // c.rootNode can not access time unles casted as SubNode
Replies
3
Boosts
0
Views
3.6k
Activity
Sep ’16
Reply to Subclass inherit from class not able to access properties
Swift doesn't have covariance for return types (yet?), and that's what would let you override rootNode in a subclass to return a SubNode. That aside, the problem is, of course, that an instance of SubNode can't be sure that it's returning a SubNode root, because it doesn't control the type of the stored properties that have nodes for values.You can work around the problem, clumsily, by giving SubNode a subRootNode property, if you don't want to force clients of the class to do a cast.A better approach, in the Swift philosopy, is to not use class inheritance at all. Instead, you'd declare a NodeProtocol that defines the shared behavior of all nodes, and put the base class behavior in a protocol extension that implements default behavior. You can still have a Node base class if you want, but ideally you don't need it, and your (no-longer-sub-)classes would just implement their versions of the protocol behavior.This is known as protocol oriented programming, and you should find a lot of discussion of it
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’16
Reply to Cannot invoke 'dataTask' with an argument list of type...
That would make very much Android programming... frankly I do not see so much the need to create so many layers in an object oriented environment but rather have in my full view the full piece of code I am working with. But of course this is a matter of taste. Somone like it horizontal, some othe ones like it vertical :-) It mins me of the bias, also being enforced in the WWDC, towards the have relationoship, oppsotie to the is one (property verus inheritance). OO theory has weel gaounded criteria to decide the relationships bwtween classes o to better model reality and I hold any attempt to steer somewhere for this make for not so easily maintanable code. But again this is a matter of taste.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’16
Reply to CloudKit reference subscription requires CKReferenceActionDeleteSelf reference?
In WWDC 2016 they said there is a parent property in CKRecord to use in order to establish hierarchical dependencies, so my question is: what about CKReference? and how to use, if the purpose is not a parent-child relationship... Anywhay, CKReference are useful to just link two records and setting the action to .deleteSelf or .none is just a part of that link.
Replies
Boosts
Views
Activity
Sep ’16
Upload to iTunes Connect error: Your app contains non-public API usage
I created a sticker pack with no code. I'm able to export to a developer .ipa file. When I try and upload using Application Loader I get an error:Your app contains non-public API usage...The app contains or inherits from non public classes in Payload/XXX/Plugins/StickerPackExtension.appex/StickerPackExtension:_MSStickerPackCollectionViewDataSourceI can't figure this out because I haven't added any frameworks or any code, its just images. Is this due to the fact that its a development build? Or are we not able to upload yet from sticker builds from XCode 8 beta 6?
Replies
6
Boosts
0
Views
1.3k
Activity
Sep ’16
Paged Watch Interface and WKCrownSequencer focus
I'm having a problem with using the CrownSequencer on a page-based watch app, where I can't find the right way to get the WKCrownSequencer to be active on the first page right after launching. The app's interface storyboard has two WKInterfaceController objects connected with a nextPage relationship segue. Here's the summary of events that happen at app launch:-awakeWithContext: is called on page 1-awakeWithContext: is called on page 2-willActivate is called on page 1-willActivate is called on page 2-didDeactivate: is called on page 2 (because page 1 is the visible page)The problem -- I'd like to access the WKCrownSequencer on both pages, but where do I put the call to -focus? If I put it in -awakeWithContext: or -willActivate, then when first launching, page 1 is visible, but the crown is always active on page 2, since these methods are called on all pages in order. Even if I called -resignFocus in -didDeactivate of page 2, that doesn't give the focus back to page 1. With the page based interface, t
Replies
1
Boosts
0
Views
493
Activity
Sep ’16
Reply to Swift3 ignoring Objective-C properties?
I sympathize. Stupid question: if you're converting code, why are you keeping Obj-C source? Could you rewrite the AKContext class hierarchy in Swift instead? I suspect your problem is some conflict across the super-/sub-class relationships. Rewriting in Swift might reveal a problem that slides under the radar in Obj-C source.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’16
Reply to Optional colon in ternary operator
Clearly you can write your code any way you’re comfortable with but the C idiom, which Swift inherits, is that:if statements are used when you want a statement?: is a shortcut to avoid temporaries when you want a valueI realise that the example in your first post is just an example, but that specific case would be much better served by filter(isIncluded:). For example, to find the even numbers in an array. let a = [1, 2, 3, 4] let b = a.filter { (i: Int) -> Bool in return i % 2 == 0 } print(b) // prints [2, 4]If you really want to get concise you can crunch this down quite dramatically.let b = a.filter { $0 % 2 == 0 }Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’16
Reply to Invalid Bundle error from iTC, cannot submit app - because 4 swift dylibs fail to embed
Also, I cannot export to an ADHOC build from xcode for the same reason. It fails on the comiling from bitcode step.Here are some snippets, anyone know how to fix these? I checked that my runtime search paths include executable_path/frameworks, loader_path/frameworks, inherited etc... all of those were already there Debug: Search Path: ['/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin', '/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/usr/lib', '/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS3.0.sdk/System/Library/Frameworks'] error: libswiftCore.dylib not found in dylib search path2016-09-14 15:33:40 +0000 /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool exited with 1 2016-09-14 15:33:40 +0000 ipatool JSON: { alerts = ( { code = 2554; description = Configuration issue: platform AppleTVSimulator.platform doesn't have any non-sim
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’16
Reply to API documentation, how to filter symbols
And where are the subclass relationships?
Replies
Boosts
Views
Activity
Sep ’16
Reply to Sending an object with MSMessage
I agree the documentation is not super clear and the Ice Cream Builder code not compiling does not help.So far, I have been able to create a new message by executing the code below in a UIViewController which inherits from MSMessagesAppViewController. I have yet to figure out a way to get the activeConversation thread to insert into, as calling this on the controller returns nil. In regards to your other questions, you do not create a send button, this exists in iMessage. Creating a message simply places it into the input field for the user to send. This makes sense, as some developers would have surely abused auto-sending capability. As far as passing your game-variables and state, the URL would be a great way to do it. You could add the key-value pairs into the URL as necessary and parse on the recipents end. MSConversation *conversation = [MSConversation new]; if (conversation) { MSMessageTemplateLayout *layout = [[MSMessageTemplateLayout alloc] init]; layout.caption = @Caption; layout.subcaption
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Sep ’16
Flagged as using Private API
When I submitted an update to my app yesterday, I got a rejection saying I was using a private API called `addAction:` (apple app ID 643351983). A thorough scrub of my code shows only one place any `addAction:` is defined / called in my (or third party) code: an autogenerated method by Core Data for one of my NSManagedObject subclasses, which has a relationship called Actions.Clearly this private API search is text-based.This generated code has been in my app since 2013, largely untouched. App review approved my app, but requested I change the method name in order to prevent future flagging. Unfortunantly this is part of my data model layer and I really don't want to change it. It's not a trivial change as I do a lot of serialization and backing up of data base on the names of my entity properties. I'd be happy to change if I was using a private API, but I'm not, and App Review simply wants me to do all this extra work this to avoid future confusion.Something changed with the private API checks aroun
Replies
0
Boosts
0
Views
754
Activity
Sep ’16
GKScene and SKNode.entity
I've been updating a SpriteKit/GameplayKit project for Xcode 8 and the new Scene Editor which allows adding Entity-Component information to a scene. I've been to move my entity code into the scene, but I'm having trouble accessing the entity from the corresponding node. As per Apple's documentation:Any SpriteKit node in the scene to which you’ve attached an entity or components automatically has a GKSKNodeComponent object to manage the relationship between the node and the the GKEntity object it represents.andAdding a GKSKNodeComponent object to an entity automatically updates the entity property of the component’s SpriteKit node (an SKNode object) to point to that entity.The new code I have to load the scene is basically as follows:guard let newTowerScene = GKScene(fileNamed: TowerScene), let rootScene = newTowerScene.rootNode as? SKScene else { return } self.view?.presentScene(rootScene, transition: SKTransition.push(with: .up, duration: 1.75))Accessing the GKScene object returns an array of proper
Replies
2
Boosts
0
Views
1.7k
Activity
Sep ’16
IAP of Prepaid or "top up" mobile data or voice
Hello,If a mobile phone operator wanted to create an App to allow purchase of prepaid or top up data or voice, it could be implemented a number of ways1. The App could request a purchase of prepaid or top up data or voice from the mobile phone operator and that would be billed to the customer's credit card held with at the mobile phone operator, not via IAP2. The App could request a purchase of top up data or voice from the mobile phone operator and that would be billed to the customer's existing post paid account with the mobile phone operator, not via IAP3. The App could use IAP as a mehcnaims for charging prepaid or top up data or voiceDoes Apple allow 1 and 2, purchase of a service, not using IAP, whcih is not delivered In App, where the customer has an existing relationship with the service provider, In fact the purchase may be for a differnet phone to the one that the customer is using the App on.Does Apple charge 30% of 3 ?Thanksjohn
Replies
1
Boosts
0
Views
496
Activity
Sep ’16