Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Bad tint color when using UIActivityViewController
Hi,I (intentionally) set the tintColor of my application's main window to white.Whenever I display a UIAlertController or a UIActivityViewController, by default that controller inherits the main window's tint, which results in unreadable white-on-white text. To fix this, I make sure to set the tintColor on the other controller's view to black before I present it.This works fine with UIAlertController. With UIActivityViewController, it fixes the Cancel button underneath the main view. However, if I press one of the more buttons on the main view, or if I navigate to the Mail app, I again get white-on-white text.How do I fix this?Thanks,Frank
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
670
Mar ’16
Reply to [NSSet intersectsSet:]: set argument is not an NSSet
Not sure if this will help or not, but, I have experienced something similar with Ordered relationships within Core Data. Here is what I ended up doing.- (void)addReportQueriesObject:(ReportQuery *)value { NSMutableOrderedSet* tempSet = [NSMutableOrderedSet orderedSetWithOrderedSet:self.reportQueries]; [tempSet addObject:value]; self.reportQueries = tempSet; }basically I have to initialize a new ordered set, add my new value to that newly allocated ordered set, THEN save that into my ManagedObject. Hope this helps!
Mar ’16
Reply to Run action only on parent sknode
Actions are not inherited from the parent, really, but the effects of property changes are. So you have 2 choices:1. When you add an action to the parent, add an inverse of the action to the children. That is, if you move the parent 10 to the left, move the children 10 to the right.2. Rethink your design. If the children don't reflect changes to parent properties, they probably shouldn't be children.If you have other reasons for associating these children with this parent, then I suggest you create a plain SKNode, and make the children subnodes of that. Then create another plain SKNode, and make the parent and first SKNode children of that. With that structure, you can chose which parts of the hierarchy you want actions to affect.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Mar ’16
Reply to Run action only on parent sknode
Right now I have:planetNode that has action to follow a path (oval) and another action to rotate by angle all the time. This node is inherited from SKSpriteNode, it also has added other things: - a mouse over effect (action for blinking node when mouse is over planet)- a mouse click (an action that should stop blinking and instead show child that is actually a square that is drawn around planet, but it should move with planet all the time when it is selected).I have disengaged planet shadow node (this is normal SKSpriteNode now) and it is just following planet on same path action, but it has own rotating action. All fine and good, but now selecting and hovering isn't working, as planet is under shadow node. Ok I understand, that I'm trying to have events on object that doesn't have them, but making shadow clickable and hoverable object type is defeating a purpose of selecting a planet as I then don't know which planet is actually under that shadow. Shadow can be same on multiple planets. Only solutio
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Mar ’16
Reply to Can anyone recommend a NSFetchedResultsController clone for OS X?
I've found some others, but couldn't find a sectioned one.Here's what I'm thinking of trying to do, perhaps someone can let me know if this is a bad idea.1) Create an SectionArrayController subclass of NSArrayController. Set its entity to the entity for the object that represents the 'sections'.2). KVO arrangedArranges within my view controller, and reload my user interface when changes are detected.The problem with this is, SectionArrayController does not report child object changes, when a object is added to the section. So if you add a object to a given section (a to many relationship), you won't get the change and the user interface will be out of sync.So I'm thinking of adding another array controller as a property to the SectionArrayController subclass..and have the section array controller kvo the array controller for the items in the section...and programmatically calling a rearrangeObjects to force a refresh.Kind of ugly set up, but I guess it's better than reinventing the wheel and writing
Mar ’16
Reply to iOS 9 Battery Widget Support
Common approaches in the past... is for individual apps to request notifications from the Battery Service and either/both: a) display battery status internally and/or b) use iOS notification pop-up when power is low. This approach requires an opt-in from the user (intentionally running the app in the background and either checking it regularly or allowing it to do iOS notifications).See:http://stackoverflow.com/questions/17...But I think using NC risks confusing the user by displaying multiple battery level indicator, where they've been trained by Apple to expect a 1:1 relationship in that example.
Mar ’16
Reply to Swift Extensions, care and feeding
>I've not really found a way of using them to structure large/complex types that feels just right.Be careful of mis-calibrating expectations... Swift is still young, still being fleshed out, still finding itself - it won't turn the corner where the new wears off for some time yet, so if you're expecting comfort similar to other, time-worn langs, it might be too early to hope for that kind of relationship just yet.In the mean time, file bugs and be patient.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’16
Reply to How can I print how many decimal places there are in a number?
Alas, your question does not make any sense given the realities of binary floating point. First up, some overall comments:Swift uses Double as its standard floating point type. double_t is a compatibility thing inherited from C code. It only works in this context because you’re importing Foundation.Swift’s Double type is defined to be an IEEE 754 ‘double’ (binary64), which means it uses binary floating point.The fact that Double uses binary floating point means that questions about decimal places don’t make a lot of sense in Swift. For example, consider this snippet: let a: Double = 0.2 let b: Double = 0.1 let c: Double = 0.3 let sum = a + b print(sum == c) // prints falseIf you look at the binary representation of these values it’s easy to see why:print(String(unsafeBitCast(a, UInt64.self), radix: 16)) // prints 3fc9_9999_9999_999a print(String(unsafeBitCast(b, UInt64.self), radix: 16)) // prints 3fb9_9999_9999_999a print(String(unsafeBitCast(c, UInt64.self), radix: 16)) // prints 3fd3_3333_3333_333
Mar ’16
ViewController appears for 2 seconds in State Restoration
I am attempting achieve State Restoration in my app. Core Data was included when the application was initially constructed, with all of its code automatically included inside of the AppDelegate.m . There is a one-to-many relationship between State entity and Country entity. The selectedState instance variable is passed to the CountryTableViewController via prepareForeSegue. The first tableviewController always appears in its original state. Unfortunately, after a Push Segue to my second tableviewController, restoration does not work. All of my tableViewControllers are created inside of StoryBoard. They all have restorationID's assigned from within StoryBoard. The initial configuration is a UINavigationController that is associated with StatesTableViewController. The StateTableViewController uses a Push Segue via another UINavigationController that is associated with CountryTableViewController. All transitions are working fine. Below is some program code, and hope you can give me advise on how to rest
1
0
470
Mar ’16
NSTreeController, is it not suppose to pick up changes to what it is binded to?
I know NSTreeController is typically used to be synced with NSOutlinedView. I'm attemting to use it to get sections for my UI (not using NSOutlineView).I have a managed object subclass, that is the section, it has a to many relationship to its items. When new managed objects are created and added to the section, NSTreeController is not automatically adding children. I know this, because I set break point in my datasource methods. The object that was added, is part of the ordered set of the section object (I can see that in the debugger) but it is not part of the NSTreeController. So if I do:-(NSInteger)numberOfObjectsInSeciton:(NSInteger)section { NSTreeNode *object = [[self.treeController.arrangedObjects childNodes]objectAtIndex:section]; NSArray *childNodes = [object childNodes]; return childNodes.count; }I get nothing. Now when i add the newly created object, and I call insertObject:atArrangedObjectIndexPath: the item is added. I guess what I'm asking is, if some other object that is a bit removed
0
0
227
Mar ’16
Reply to Overriding function signature--documented?
A Swift function signature includes its names, input parameters and its return type. So, if you wrote this:let f = E().arbitraryFactory()what would f's type be? The compiler would complain that f's type is ambiguous; it's not clear which of the two functions should be called, whether a B or an E should be returned. You'd need to make it explicit:let f : B = E().arbitraryFactory()The reason one requires an override and the other does not: returning an E doesn't conform to the 'super' function signature, but returning a B does, because a B is an A. What matters with the inherited function is that, when called, an A is returned; the overridden signature is allowed to be more specific about its return type.With the identity function the same can't be said; the 'overridden' signature type isn't general enough with its input arguments - E().identify(A()) would call D's function, not E's, because E's isn't general enough.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’16
Swift "NSNumber" equivalent?
Under Obj-C I used NSNumbers a lot because it allowed you to convert between various types with ease, and made storage in other collections easy. In Swift many of these limitations have been removed and the built-in base types like Int and Double do much of this. But this means that the generic Number isn't there and sometimes this is a useful simplification. So given that the Swift types are value types, and those can be inherited, is there any reason Double and Int couldn't be decendants of Number? Or is such a thing possible now?
2
0
9.3k
Mar ’16
Reply to Swift "NSNumber" equivalent?
>> But this means that the generic Number isn't there and sometimes this is a useful simplification. You can still use NSNumber explicitly in Swift, if you want to.>> So given that the Swift types are value types, and those can be inherited,They can't. Double and Int are structs. There is no inheritance for Swift structs.>> is there any reason Double and Int couldn't be decendants of Number? They don't really have the same behavior, beyond the basics.>> Or is such a thing possible now?You could define your own protocol that includes behavior common to Double and Int, and extend those classes to conform to it. But my guess is that it's going to get pretty ugly, because you'll have trouble with things like literals, unless you make your protocol very complicated.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’16
Bad tint color when using UIActivityViewController
Hi,I (intentionally) set the tintColor of my application's main window to white.Whenever I display a UIAlertController or a UIActivityViewController, by default that controller inherits the main window's tint, which results in unreadable white-on-white text. To fix this, I make sure to set the tintColor on the other controller's view to black before I present it.This works fine with UIAlertController. With UIActivityViewController, it fixes the Cancel button underneath the main view. However, if I press one of the more buttons on the main view, or if I navigate to the Mail app, I again get white-on-white text.How do I fix this?Thanks,Frank
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
670
Activity
Mar ’16
[NSSet intersectsSet:]: set argument is not an NSSet
I get this crash, when adding an object to its parent and the relationship was configured to be ordered.I googled around, saw various suggested workarounds, some date back all the way to 2011. Anyway I can get the generated property to be an ordered set, or do I have to override all these manually?
Replies
5
Boosts
0
Views
2.8k
Activity
Mar ’16
Reply to [NSSet intersectsSet:]: set argument is not an NSSet
Not sure if this will help or not, but, I have experienced something similar with Ordered relationships within Core Data. Here is what I ended up doing.- (void)addReportQueriesObject:(ReportQuery *)value { NSMutableOrderedSet* tempSet = [NSMutableOrderedSet orderedSetWithOrderedSet:self.reportQueries]; [tempSet addObject:value]; self.reportQueries = tempSet; }basically I have to initialize a new ordered set, add my new value to that newly allocated ordered set, THEN save that into my ManagedObject. Hope this helps!
Replies
Boosts
Views
Activity
Mar ’16
Run action only on parent sknode
As title says. How to run SKAction only on parent only (children not affected by it)?I have some SKSpriteNodes with children, but I would like to manually control which actions are run on each children and that actions are not inherited from parent
Replies
9
Boosts
0
Views
1.9k
Activity
Mar ’16
Reply to Run action only on parent sknode
Actions are not inherited from the parent, really, but the effects of property changes are. So you have 2 choices:1. When you add an action to the parent, add an inverse of the action to the children. That is, if you move the parent 10 to the left, move the children 10 to the right.2. Rethink your design. If the children don't reflect changes to parent properties, they probably shouldn't be children.If you have other reasons for associating these children with this parent, then I suggest you create a plain SKNode, and make the children subnodes of that. Then create another plain SKNode, and make the parent and first SKNode children of that. With that structure, you can chose which parts of the hierarchy you want actions to affect.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Mar ’16
Reply to Run action only on parent sknode
Right now I have:planetNode that has action to follow a path (oval) and another action to rotate by angle all the time. This node is inherited from SKSpriteNode, it also has added other things: - a mouse over effect (action for blinking node when mouse is over planet)- a mouse click (an action that should stop blinking and instead show child that is actually a square that is drawn around planet, but it should move with planet all the time when it is selected).I have disengaged planet shadow node (this is normal SKSpriteNode now) and it is just following planet on same path action, but it has own rotating action. All fine and good, but now selecting and hovering isn't working, as planet is under shadow node. Ok I understand, that I'm trying to have events on object that doesn't have them, but making shadow clickable and hoverable object type is defeating a purpose of selecting a planet as I then don't know which planet is actually under that shadow. Shadow can be same on multiple planets. Only solutio
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Mar ’16
Reply to Can anyone recommend a NSFetchedResultsController clone for OS X?
I've found some others, but couldn't find a sectioned one.Here's what I'm thinking of trying to do, perhaps someone can let me know if this is a bad idea.1) Create an SectionArrayController subclass of NSArrayController. Set its entity to the entity for the object that represents the 'sections'.2). KVO arrangedArranges within my view controller, and reload my user interface when changes are detected.The problem with this is, SectionArrayController does not report child object changes, when a object is added to the section. So if you add a object to a given section (a to many relationship), you won't get the change and the user interface will be out of sync.So I'm thinking of adding another array controller as a property to the SectionArrayController subclass..and have the section array controller kvo the array controller for the items in the section...and programmatically calling a rearrangeObjects to force a refresh.Kind of ugly set up, but I guess it's better than reinventing the wheel and writing
Replies
Boosts
Views
Activity
Mar ’16
Reply to iOS 9 Battery Widget Support
Common approaches in the past... is for individual apps to request notifications from the Battery Service and either/both: a) display battery status internally and/or b) use iOS notification pop-up when power is low. This approach requires an opt-in from the user (intentionally running the app in the background and either checking it regularly or allowing it to do iOS notifications).See:http://stackoverflow.com/questions/17...But I think using NC risks confusing the user by displaying multiple battery level indicator, where they've been trained by Apple to expect a 1:1 relationship in that example.
Replies
Boosts
Views
Activity
Mar ’16
Reply to Swift Extensions, care and feeding
>I've not really found a way of using them to structure large/complex types that feels just right.Be careful of mis-calibrating expectations... Swift is still young, still being fleshed out, still finding itself - it won't turn the corner where the new wears off for some time yet, so if you're expecting comfort similar to other, time-worn langs, it might be too early to hope for that kind of relationship just yet.In the mean time, file bugs and be patient.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’16
Reply to How can I print how many decimal places there are in a number?
Alas, your question does not make any sense given the realities of binary floating point. First up, some overall comments:Swift uses Double as its standard floating point type. double_t is a compatibility thing inherited from C code. It only works in this context because you’re importing Foundation.Swift’s Double type is defined to be an IEEE 754 ‘double’ (binary64), which means it uses binary floating point.The fact that Double uses binary floating point means that questions about decimal places don’t make a lot of sense in Swift. For example, consider this snippet: let a: Double = 0.2 let b: Double = 0.1 let c: Double = 0.3 let sum = a + b print(sum == c) // prints falseIf you look at the binary representation of these values it’s easy to see why:print(String(unsafeBitCast(a, UInt64.self), radix: 16)) // prints 3fc9_9999_9999_999a print(String(unsafeBitCast(b, UInt64.self), radix: 16)) // prints 3fb9_9999_9999_999a print(String(unsafeBitCast(c, UInt64.self), radix: 16)) // prints 3fd3_3333_3333_333
Replies
Boosts
Views
Activity
Mar ’16
ViewController appears for 2 seconds in State Restoration
I am attempting achieve State Restoration in my app. Core Data was included when the application was initially constructed, with all of its code automatically included inside of the AppDelegate.m . There is a one-to-many relationship between State entity and Country entity. The selectedState instance variable is passed to the CountryTableViewController via prepareForeSegue. The first tableviewController always appears in its original state. Unfortunately, after a Push Segue to my second tableviewController, restoration does not work. All of my tableViewControllers are created inside of StoryBoard. They all have restorationID's assigned from within StoryBoard. The initial configuration is a UINavigationController that is associated with StatesTableViewController. The StateTableViewController uses a Push Segue via another UINavigationController that is associated with CountryTableViewController. All transitions are working fine. Below is some program code, and hope you can give me advise on how to rest
Replies
1
Boosts
0
Views
470
Activity
Mar ’16
NSTreeController, is it not suppose to pick up changes to what it is binded to?
I know NSTreeController is typically used to be synced with NSOutlinedView. I'm attemting to use it to get sections for my UI (not using NSOutlineView).I have a managed object subclass, that is the section, it has a to many relationship to its items. When new managed objects are created and added to the section, NSTreeController is not automatically adding children. I know this, because I set break point in my datasource methods. The object that was added, is part of the ordered set of the section object (I can see that in the debugger) but it is not part of the NSTreeController. So if I do:-(NSInteger)numberOfObjectsInSeciton:(NSInteger)section { NSTreeNode *object = [[self.treeController.arrangedObjects childNodes]objectAtIndex:section]; NSArray *childNodes = [object childNodes]; return childNodes.count; }I get nothing. Now when i add the newly created object, and I call insertObject:atArrangedObjectIndexPath: the item is added. I guess what I'm asking is, if some other object that is a bit removed
Replies
0
Boosts
0
Views
227
Activity
Mar ’16
Reply to Overriding function signature--documented?
A Swift function signature includes its names, input parameters and its return type. So, if you wrote this:let f = E().arbitraryFactory()what would f's type be? The compiler would complain that f's type is ambiguous; it's not clear which of the two functions should be called, whether a B or an E should be returned. You'd need to make it explicit:let f : B = E().arbitraryFactory()The reason one requires an override and the other does not: returning an E doesn't conform to the 'super' function signature, but returning a B does, because a B is an A. What matters with the inherited function is that, when called, an A is returned; the overridden signature is allowed to be more specific about its return type.With the identity function the same can't be said; the 'overridden' signature type isn't general enough with its input arguments - E().identify(A()) would call D's function, not E's, because E's isn't general enough.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’16
Swift "NSNumber" equivalent?
Under Obj-C I used NSNumbers a lot because it allowed you to convert between various types with ease, and made storage in other collections easy. In Swift many of these limitations have been removed and the built-in base types like Int and Double do much of this. But this means that the generic Number isn't there and sometimes this is a useful simplification. So given that the Swift types are value types, and those can be inherited, is there any reason Double and Int couldn't be decendants of Number? Or is such a thing possible now?
Replies
2
Boosts
0
Views
9.3k
Activity
Mar ’16
Reply to Swift "NSNumber" equivalent?
>> But this means that the generic Number isn't there and sometimes this is a useful simplification. You can still use NSNumber explicitly in Swift, if you want to.>> So given that the Swift types are value types, and those can be inherited,They can't. Double and Int are structs. There is no inheritance for Swift structs.>> is there any reason Double and Int couldn't be decendants of Number? They don't really have the same behavior, beyond the basics.>> Or is such a thing possible now?You could define your own protocol that includes behavior common to Double and Int, and extend those classes to conform to it. But my guess is that it's going to get pretty ugly, because you'll have trouble with things like literals, unless you make your protocol very complicated.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’16