Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Best practice for checking if an enum exists in iOS version?
CoreBluetooth has refactored both their CBCentralManager and CBPeripheralManager to inherit from CBManager.In this new class, the CBManagerState enumeration exists. This is kind of a big change.What is the best strategy for supporting both CBManagerState along side with CBCentralManagerState and CBPeripheralManagerState enums?This code begins to look quite messy. I don't know of a way to check enum availability, so I check the class that this new property is used in instead.- (void)centralManagerDidUpdateState:(CBCentralManager *)central { if ([CBManager class]) { self.updatedStateBlock((CBManagerState)central.state); } else { self.updatedStateBlock((CBCentralManagerState)central.state); } }Previously my updatedStateBlock was defined as such, but now the named ns_enumeration has changed its name.@property (nonatomic, copy) void (^updatedStateBlock)(CBCentralManagerState state);I could possibly refactor my framework API to pass the manager instead, and then the caller would have to query the state pro
3
0
4.3k
Jun ’16
addCoordinatedAnimations mangles scale transform animations
Since tvOS 9.2, the addCoordinatedAnimations(-:completion:) method of UIFocusAnimationCoordinator has exhibited a strange behavior. Assume you have a collection view whose cells use either affine or 3D scale transforms to scale-up their contents when focused:override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { coordinator.addCoordinatedAnimations({ if self.focused { self.focusEffectsContainer.transform = CGAffineTransformMakeScale(1.158, 1.158) } else { self.focusEffectsContainer.transform = CGAffineTransformIdentity } }, completion: nil) }If you scroll through the collection view very quickly, cells that acquire and then immediately lose focus before being scrolled into the visible boundswill appear to be scaled-down for a few moments before returning to their identity transform states.Check out a video of the bug here. You can also download the sample project here.My best guess is that UIFocusAnimationCoordinator’s addCoord
3
0
712
Jun ’16
Reply to Having problems with Core Data?
Okay, after watching the video linked to by malhal I found a work-around for Beta 1 that solves the ownership of the NSManagedObject subclass problem. By this I mean being able to manually generate the subclass and your project being in control of the primary class definition.In the core data model select the Entity you would like to control. Select the Data Model Inspector. Under the Class category there is a Codegen drop-down. Selecting Manual/None right now still auto-gens it (seems to be a bug). But if you select Category/Extension it will only create the properties/relationships definitions in an internal extension file stored in the DerivedData folder.Now manually generate the entity subclass. There is yet another bug here that generates those three files: the main class definition, the extension for properties and relationships and that weirdo file with the single macro defined. Simply delete all the files except the <Class>+CoreDataClass.swift file and everything should be okay
Topic: App & System Services SubTopic: Core OS Tags:
Jun ’16
relationship coredata
I need help, I'm starting to use CoreData and I have some doubts about the relationship:I have two entities, Categories and Items:Category entity has the attributes: nameItems entity has the attributes: name, price, and category (entity attribute name Category)How do I insert the record in enteidade Items using the entity's name atribuito Category?
1
0
280
Jun ’16
Reply to base class root class
A base class is an ancestor class (i.e. parent, grandparent, great-grandparent, etc). A root class is a class that doesn't have any ancestors.In Objective-C, you can define multiple root classes if you want. Typically you inherit from a single root via NSObject, but there are cases (NSProxy) that have a different hierarchy. In Swift, I'm not sure the concept of a root class (as a special thing) is really used, since it's common for a class not to have a parent, and there's nothing very special about that situation.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’16
Efficient implementation of CoreData FetchedResultsController
Hi AllI have a question on the most efficient implementation of coredata NSFetchedRestultsController. Basically, I have 2 UITableViewControllers. UITableViewController No 1 shows a list of Parent entities and UITableViewController No 2 shows list of child entities for each parent. (Parent has one-to-Many relationship to child).There is an Add button on the navigation bar to Add a new Parent or a New Child (to a particular parent) on each UITableviewController respectively.The way I have implemented it currently is that both UITableViewControllers have FetchedResultsController methods implemented. So the Parent UITableviewcontroller has a FetchedResultsController to get a list of all parents and also the controller helps to add/remove New Parent entities along with the smooth animations which are default to master-detail style implementation.For the child UITableviewcontroller, there is an analogus FetchedResultsController with a predicate to fetch the children of a particular parent. Rest everything
1
0
421
Jun ’16
override viewDidUnload unavailable
When I try to override the function viewDidUnload method for a class which inherits from UIViewController and MPMediaPickerControllerDelegate, I get an error which says, Cannot override 'viewDidUnload' which has been marked unavailable.What do I do to fix this?
2
0
3.6k
Jun ’16
Rudimentary tab-controller use-case crashes
In Xcode 7.3.1 I perform this straigtfoward use-case resulting in crash (see below). The objective of this exercise is to add an additional tab (and view controller) to the tab controller.1) Create New Project OSx Cocoa swift project2) Open story board (by double-clicking storyboard)3) Add Tab View Controller to canvas4) Add View Controller to canvas5) Control-drag from (3) to (4)6) In resulting 'Relationship Segue' pop-up menu choose 'tab items'7) Xcode crashes. ------------------------------------------------Exception Type: EXC_CRASH (SIGABRT)Exception Codes: 0x0000000000000000, 0x0000000000000000Exception Note: EXC_CORPSE_NOTIFYApplication Specific Information:ProductBuildVersion: 7D1014UNCAUGHT EXCEPTION (NSRangeException): *** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]UserInfo: (null)Hints: 0: Creation Backtrace for Notification Token: 0 -[_DVTNotificationReceiver initWithBlock:queue:] (in DVTFoundation) 1 -[NSNotificationCenter(DVTNSNotificationCenterAdditions) dvt_addObserver
0
0
255
Jun ’16
UI: iCloud only mode opt in, or separate 'Local and iCloud' sections?
I've been workin on an app. It uses Core Data allowing the user to create and group a list of records (like many Core Data apps). It's a Mac app.So I'm thinking of adding iCloud support (using the CloudKit API) and syncing data from iCloud with Core Data. I'm on the fence about how I should design my code to handle users who do not opt in to using iCloud and users who may opt in and change their mind and turn the setting off. As a user, I prefer having both iCloud and local areas in the UI, so if I opt into iCloud I don't have to place every single entry in iCloud because 1) it's not free and 2) often I don't need to or want to put something in iCloud.If I remember correctly, the last time I checked out the iCloud design guidelines devs were discouraged from providing both local and cloud options at the same time (I believe we are/were encouraged in offering all or nothing...use iCloud or don't use it). However, Apple does not do this in Notes,...you can add a local note On my Mac in the sidebar even with iCl
1
0
214
Jun ’16
Reply to add a speacial circle View to MKMapView
You could compute the size using the MapKit functions that convert UIKit points to MapKit map points and calculate meters between map points. Or you could determine empirically if there is a linear relationship between the magnitude of the pinch and the change in map zoom level, and just apply the same scaling factor that the map view uses. The latter is a little more risky as it depends on the internal implementation of the map view.
Jun ’16
MediaPlayer MPVolumeView
I am working with the MediaPlayer library. I want to know how to control the volume with code. I found the MPVolumeView class reference, but I don't know what to do with the class. Is that something I inherit by a subclass?
0
0
190
Jul ’16
Reply to How many geometries is too much?
Do you really need to create a different instance of SCNGeometry for each hexagon ?Why not re-using the same instance (or a set of instances with different materials applied) ?That may be the source of your performance problem.A number of nodes can use the same geometry and that makes rendering quicker.From the documentation:You can easily copy geometries and change their materials. A geometry object manages the association between immutable vertex data and a mutable assignment of materials. To make a geometry appear more than once in the same scene with a different set of materials, use its inherited copy method. The copy shares the underlying vertex data of the original, but can be assigned materials independently. You can thus make many copies of a geometry without incurring a significant cost to rendering performance.You would only need to make as many copies of the SCNGeometry as you have different materials. Then, your hexagone nodes could be assigned e.g geometry1, geometry2, geometry3, geomet
Topic: Graphics & Games SubTopic: SceneKit Tags:
Jul ’16
Best practice for checking if an enum exists in iOS version?
CoreBluetooth has refactored both their CBCentralManager and CBPeripheralManager to inherit from CBManager.In this new class, the CBManagerState enumeration exists. This is kind of a big change.What is the best strategy for supporting both CBManagerState along side with CBCentralManagerState and CBPeripheralManagerState enums?This code begins to look quite messy. I don't know of a way to check enum availability, so I check the class that this new property is used in instead.- (void)centralManagerDidUpdateState:(CBCentralManager *)central { if ([CBManager class]) { self.updatedStateBlock((CBManagerState)central.state); } else { self.updatedStateBlock((CBCentralManagerState)central.state); } }Previously my updatedStateBlock was defined as such, but now the named ns_enumeration has changed its name.@property (nonatomic, copy) void (^updatedStateBlock)(CBCentralManagerState state);I could possibly refactor my framework API to pass the manager instead, and then the caller would have to query the state pro
Replies
3
Boosts
0
Views
4.3k
Activity
Jun ’16
addCoordinatedAnimations mangles scale transform animations
Since tvOS 9.2, the addCoordinatedAnimations(-:completion:) method of UIFocusAnimationCoordinator has exhibited a strange behavior. Assume you have a collection view whose cells use either affine or 3D scale transforms to scale-up their contents when focused:override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { coordinator.addCoordinatedAnimations({ if self.focused { self.focusEffectsContainer.transform = CGAffineTransformMakeScale(1.158, 1.158) } else { self.focusEffectsContainer.transform = CGAffineTransformIdentity } }, completion: nil) }If you scroll through the collection view very quickly, cells that acquire and then immediately lose focus before being scrolled into the visible boundswill appear to be scaled-down for a few moments before returning to their identity transform states.Check out a video of the bug here. You can also download the sample project here.My best guess is that UIFocusAnimationCoordinator’s addCoord
Replies
3
Boosts
0
Views
712
Activity
Jun ’16
Is there any place to download xcode 4.2 for snow leopard still for a mac book os 10.6.8? Trying to start to develop apps on the machine.
I have inherited a mac book os 10.6.8. Is there any place still I can download xcode 4.2 for snow leopard so I can use the machine for building apps?I have not found anything in my own google searches.Thanks.
Replies
7
Boosts
0
Views
3.2k
Activity
Jun ’16
Reply to Casting from array of protocol to array of parent protocol?
I guess answer is that Array<MyProtocol> doesn't inherit from Array<AnyObject> ... I was thinking of the contents as the type, not Array<Type>. Seems .map is the recommended solution.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’16
Reply to Having problems with Core Data?
Okay, after watching the video linked to by malhal I found a work-around for Beta 1 that solves the ownership of the NSManagedObject subclass problem. By this I mean being able to manually generate the subclass and your project being in control of the primary class definition.In the core data model select the Entity you would like to control. Select the Data Model Inspector. Under the Class category there is a Codegen drop-down. Selecting Manual/None right now still auto-gens it (seems to be a bug). But if you select Category/Extension it will only create the properties/relationships definitions in an internal extension file stored in the DerivedData folder.Now manually generate the entity subclass. There is yet another bug here that generates those three files: the main class definition, the extension for properties and relationships and that weirdo file with the single macro defined. Simply delete all the files except the <Class>+CoreDataClass.swift file and everything should be okay
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jun ’16
relationship coredata
I need help, I'm starting to use CoreData and I have some doubts about the relationship:I have two entities, Categories and Items:Category entity has the attributes: nameItems entity has the attributes: name, price, and category (entity attribute name Category)How do I insert the record in enteidade Items using the entity's name atribuito Category?
Replies
1
Boosts
0
Views
280
Activity
Jun ’16
Reply to base class root class
A base class is an ancestor class (i.e. parent, grandparent, great-grandparent, etc). A root class is a class that doesn't have any ancestors.In Objective-C, you can define multiple root classes if you want. Typically you inherit from a single root via NSObject, but there are cases (NSProxy) that have a different hierarchy. In Swift, I'm not sure the concept of a root class (as a special thing) is really used, since it's common for a class not to have a parent, and there's nothing very special about that situation.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’16
Efficient implementation of CoreData FetchedResultsController
Hi AllI have a question on the most efficient implementation of coredata NSFetchedRestultsController. Basically, I have 2 UITableViewControllers. UITableViewController No 1 shows a list of Parent entities and UITableViewController No 2 shows list of child entities for each parent. (Parent has one-to-Many relationship to child).There is an Add button on the navigation bar to Add a new Parent or a New Child (to a particular parent) on each UITableviewController respectively.The way I have implemented it currently is that both UITableViewControllers have FetchedResultsController methods implemented. So the Parent UITableviewcontroller has a FetchedResultsController to get a list of all parents and also the controller helps to add/remove New Parent entities along with the smooth animations which are default to master-detail style implementation.For the child UITableviewcontroller, there is an analogus FetchedResultsController with a predicate to fetch the children of a particular parent. Rest everything
Replies
1
Boosts
0
Views
421
Activity
Jun ’16
Swift 3 setter conflict with "isProperty" and "property"
In Swift 1.x and 2.x on my model I've had property which is a relationship, and isProperty which is a boolean. In Swift 3 I am getting a: Setter for 'property' with Objectice-C selector 'SetProperty:' conflicts with setter for 'isProperty' with the same Objectice-C selector. But I don't quite understand how.
Replies
0
Boosts
0
Views
377
Activity
Jun ’16
override viewDidUnload unavailable
When I try to override the function viewDidUnload method for a class which inherits from UIViewController and MPMediaPickerControllerDelegate, I get an error which says, Cannot override 'viewDidUnload' which has been marked unavailable.What do I do to fix this?
Replies
2
Boosts
0
Views
3.6k
Activity
Jun ’16
Rudimentary tab-controller use-case crashes
In Xcode 7.3.1 I perform this straigtfoward use-case resulting in crash (see below). The objective of this exercise is to add an additional tab (and view controller) to the tab controller.1) Create New Project OSx Cocoa swift project2) Open story board (by double-clicking storyboard)3) Add Tab View Controller to canvas4) Add View Controller to canvas5) Control-drag from (3) to (4)6) In resulting 'Relationship Segue' pop-up menu choose 'tab items'7) Xcode crashes. ------------------------------------------------Exception Type: EXC_CRASH (SIGABRT)Exception Codes: 0x0000000000000000, 0x0000000000000000Exception Note: EXC_CORPSE_NOTIFYApplication Specific Information:ProductBuildVersion: 7D1014UNCAUGHT EXCEPTION (NSRangeException): *** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]UserInfo: (null)Hints: 0: Creation Backtrace for Notification Token: 0 -[_DVTNotificationReceiver initWithBlock:queue:] (in DVTFoundation) 1 -[NSNotificationCenter(DVTNSNotificationCenterAdditions) dvt_addObserver
Replies
0
Boosts
0
Views
255
Activity
Jun ’16
UI: iCloud only mode opt in, or separate 'Local and iCloud' sections?
I've been workin on an app. It uses Core Data allowing the user to create and group a list of records (like many Core Data apps). It's a Mac app.So I'm thinking of adding iCloud support (using the CloudKit API) and syncing data from iCloud with Core Data. I'm on the fence about how I should design my code to handle users who do not opt in to using iCloud and users who may opt in and change their mind and turn the setting off. As a user, I prefer having both iCloud and local areas in the UI, so if I opt into iCloud I don't have to place every single entry in iCloud because 1) it's not free and 2) often I don't need to or want to put something in iCloud.If I remember correctly, the last time I checked out the iCloud design guidelines devs were discouraged from providing both local and cloud options at the same time (I believe we are/were encouraged in offering all or nothing...use iCloud or don't use it). However, Apple does not do this in Notes,...you can add a local note On my Mac in the sidebar even with iCl
Replies
1
Boosts
0
Views
214
Activity
Jun ’16
Reply to add a speacial circle View to MKMapView
You could compute the size using the MapKit functions that convert UIKit points to MapKit map points and calculate meters between map points. Or you could determine empirically if there is a linear relationship between the magnitude of the pinch and the change in map zoom level, and just apply the same scaling factor that the map view uses. The latter is a little more risky as it depends on the internal implementation of the map view.
Replies
Boosts
Views
Activity
Jun ’16
MediaPlayer MPVolumeView
I am working with the MediaPlayer library. I want to know how to control the volume with code. I found the MPVolumeView class reference, but I don't know what to do with the class. Is that something I inherit by a subclass?
Replies
0
Boosts
0
Views
190
Activity
Jul ’16
Reply to How many geometries is too much?
Do you really need to create a different instance of SCNGeometry for each hexagon ?Why not re-using the same instance (or a set of instances with different materials applied) ?That may be the source of your performance problem.A number of nodes can use the same geometry and that makes rendering quicker.From the documentation:You can easily copy geometries and change their materials. A geometry object manages the association between immutable vertex data and a mutable assignment of materials. To make a geometry appear more than once in the same scene with a different set of materials, use its inherited copy method. The copy shares the underlying vertex data of the original, but can be assigned materials independently. You can thus make many copies of a geometry without incurring a significant cost to rendering performance.You would only need to make as many copies of the SCNGeometry as you have different materials. Then, your hexagone nodes could be assigned e.g geometry1, geometry2, geometry3, geomet
Topic: Graphics & Games SubTopic: SceneKit Tags:
Replies
Boosts
Views
Activity
Jul ’16