Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

Reply to Exact meaning of 'Super'
They are three different things that happen to use the same word super.1. The superclass of B is UIView (assuming you didn't actually declare B to be a subclass of A). This is a relationship between the classes.2. If you did '[anA addSubview: someB]', the superview of the instance of B is an instance of A. This is a relationship between instances of the classes.3. In '[super viewDidLoad]', 'super' means the same object as 'self', so the class of this 'super' is B. However, by using 'super', you're telling the compiler that you do not want to invoke class B's 'viewDidLoad' method, but its superclass's 'viewDidLoad'. That means UIView's viewDidLoad, not A's.
Topic: UI Frameworks SubTopic: UIKit Tags:
Feb ’16
Subclass implementing its own delegate protocol
Hey guys,is it OK for a subclass to implement its own delegate protocol? I have a subclass of UIScrollView which needs to respond to events like scrollViewDidEndDecelerating and scrollViewDidScroll. Therefore, I had to set the delegate property to self and implement the delegate methods inside the subclass. Nevertheless, other classes should still be able to receive these events too, as if they were using the superclass. For example, I want my subclass to do something special when the inherited scrollview ends scrolling, though the external delegate still needs to be informed about the event. Instances of the subclass and the subclass itself use the same delegate object/property. Is this even possible and would it be a safe approach or should the delegate used within the subclass get its own, private property? I appreciate any help you can provide!Cheers,Alex 🙂
Topic: UI Frameworks SubTopic: UIKit Tags:
5
0
3.2k
Feb ’16
Ways to 'persist' CloudKit data
The 'Designing for CloudKit' section of the iCloud Design Guide states that CloudKit is a service for moving data to and from iCloud and sharing data between users of your app. It’s your responsibility to convert model objects to records that you save using CloudKit, and to fetch changes made by other users and apply those changes to your model objects.Many CloudKit tutorials that I have followed don't make use of model objects. This results in data should the internet become unavailable. What is the best way to model objects and their relationships that fetch from CloudKit?
3
0
1.1k
Feb ’16
Reply to NSURLSessionDataTask vs NSURLSessionDownloadTask (NSURLSessionTaskState behavior)
You can illustrate this difference with much simpler code.var dataTask: NSURLSessionDataTask? var downloadTask: NSURLSessionDownloadTask? func dataTest() { let request = NSURLRequest(URL: NSURL(string: https://www.apple.com)!) self.dataTask = NSURLSession.sharedSession().dataTaskWithRequest(request) { (data, response, error) in print(self.dataTask!.state.rawValue) self.dataTask = nil } self.dataTask!.resume() } func downloadTest() { let request = NSURLRequest(URL: NSURL(string: https://www.apple.com)!) self.downloadTask = NSURLSession.sharedSession().downloadTaskWithRequest(request) { (fileURL, response, error) in print(self.downloadTask!.state.rawValue) self.downloadTask = nil } self.downloadTask!.resume() }dataTest() prints 3 ( .Completed) and downloadTest() prints 0 ( .Running). I’d call that a bug. The exact relationship between the completion block (or completion delegate callback) and the state property is not documented, but I think it’s reasonable to expect them to be consistent between the v
Feb ’16
Reply to Xcode 7.2.1 Breaks Swift & Objective-C Integration
I have a similar issue with Xcode 7.2.1. While my project still builds/runs as expected, I no longer get auto-completion, syntax highlighting, or ability to jump to definition for any symbol that is defined in Objective-C and used/referenced in Swift.For example, many of my view controllers are written in Swift and Xcode autocompletes/highlights/jumps to their own functions/properties without issue. However, functions/properties inherited from the common base class (written in Objective-C and imported via bridging header) do not auto-complete and are not syntax highlighted/can't find any definition to jump to. Building/running still works and I haven't observed any other issues. Objective-C files seem to have no issue (recognizing both Objective-C symbols as well as Swift symbols imported from MyProject-Swift.h)Interesting to note that the issue seems to go away when I clean the project. It only stops recognizing Objective-C symbols (inside Swift files) when I build/run the project and Xcode begins I
Feb ’16
Reply to Ways to 'persist' CloudKit data
>I don't understand this. Perhaps you can restate.A typo! When there is no internet available and the app is not loaded in memory, the data does not exist on the phone as there is no model for it to persist to! Currently, I am fetching CloudKit data and loading it straight in to a table view. I believe I need to have Swift classes representing each Record Type in CloudKit, and use subscriptions to check for changes in the data.An example:I have two record types: 'Specie' and 'Sighting'. In CloudKit, 'Sighting' has a 'specie' field of type Reference. This models the one-to-many relationship. I think I need to create a Specie.swift and a Sighting.swift class and fetch the CloudKit data from within these classes. Then, whenever there is no internet connection, the table view is still able to fetch the data persisted to my model. Specie records are read only so there would never be synch issues.Thanks!Edit: This extract from tuts+ Code sums up my point quite well: CloudKit doesn't offer local storage,
Feb ’16
Reply to NSArrayController.add - how to get the result
First: stop flailing. Randomly trying different approaches just leads to more questions than answers, and muddies the waters.Second: understand that NSArrayController works. It's been around for a long time. It's easy, in situations like this, to get into the mindset that it's doing something weird. It's not.You can't understand NSArrayController without understanding something about KVO (key-value observing). In the 3-step sequence you tried, of course you got two entries in the table, because that's what you asked for. In step 1, you asked the array controller to add a new object to your data model for you. In step 2, you added a new object yourself. But because you didn't do that KVO-compliantly, you needed step 3 to cause the UI to update.Important: the array controller is not a container. It is a glue object (a mediating controller, if you want a MVC name for it) that handles certain aspects of the relationship between a data model and a UI element such as a table view. It pretends that it conta
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’16
Reply to getting this error message any help here?
It's fairly clear. Your storyboard has a scene (created by dragging a view controller onto the IB canvas some time in the past) which doesn't have any relationships (segues, containment, etc) with any other scene, nor is it marked as your storyboard's initial scene.It also has no identifier, so it can't be instantiated in code.In other words, the scene is unreachable — can never be used.If this is just some placeholder where you're keeping an unused piece of the UI, you don't have to do anything. Otherwise you need to figure out what the scene is supposed to be connected to.
Feb ’16
Reply to PacketTunnel - server down
I believe the lifecycle of your NEPacketTunnelProvider instance is completely in the control of the system. Same for the process in which your extension is running. Once you call cancelTunnelWithError: inside your extension and your stopTunnelWithReason:completionHandler: method is called inside your extension, the NEPacketTunnelProvider instance may be deinit'd at any time and the extension process may be terminated/killed at any time. In your containing app, assuming it's running (which you cannot guarantee AFAIK), you could set a timer when the tunnel stops and retry again when the timer expires.The docs are not exactly verbose, but I think the proper way to handle temporary and short networking issues that cause your tunnel to go down is to use the reasserting property inside your extension. The reasserting property is inherited from NETunnelProvider. So if your tunnel is disconnected because of a networking problem (e.g. the tunnel server severs the connection for any reason), you can set reasse
Feb ’16
iOS Enterprise App not from AppStore – any warranty issues?
We want to distribute a non-AppStore-app to our users over MDM (our users happen to be consumers rather than employees). As our users will have enrolled in our MDM service, their devices will already have established a trust relationship with us, so our app will already be trusted. Our app is not coming from the store, so it will not have been reviewed by Apple. A contact of mine told me that if a device has a non-AppStore-app installed, Apple may consider that device’s warranty to be void, and may refuse to repair it under warranty. It seems unlikely to me that that would be the case for enterprise apps delivered over MDM, but I would like to be sure. Can anyone verify that the Apple device warranty will still be valid when the device has a non-AppStore enterprise app delivered over MDM installed on it?
1
0
246
Feb ’16
Reply to Recursive enum 'Optional<Wrapped>' is not marked 'indirect'
Xcode stores information about your project in ~/Library/Developer/Xcode/DerivedData/ppp-hhh, where ppp is the project name and hhh is a hash of the path to the project (technically this is the workspace, not the project, but if you’re not using workspaces your projects have an embedded workspace so it ends up being the same thing). If you create a project with the same name in the same directory, these values end up being the same, so you inherit the derived data directory from your previous project. Normally this inherited derived data directory isn’t a problem. For example, with errors like this, once you successfully build the project, Xcode notices its mistake and cleans up. However, in some cases you will need to trash the problematic derived data directory. In that case it’s worthwhile filing a bug against Xcode because it really should deal with this stuff. Make sure you keep a copy of the derived data directory to attach to the bug.I see this all the time because I create a lot of t
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’16
Reply to Adding iCloud capability crashes Xcode
Thank you. Since my last post, I installed net.xxxx.foo2 onto my iPhone and iPad, and edited documents on one device and then the other device, watching them update via iCloud. Quite nice. I still don't know why net.xxxx.foo would not allow me to add the iCloud capabilities. The trail of clues may be too muddled at this point. Plus, I'm littering my Member Center with empty iCloud Containers while I thrash with different bundle IDs. (I see no way to delete useless iCloud Containers, so I guess they'll be my lifelong tatoos.) Seems to me that If I pursue this mystery any further, I should start fresh with a new project, and try to carefully reproduce my problem. Thanks bob133. If you have recommended reading that helps me understand the relationships between App ID, bundle identifier, product name, etc ... let me know.
Feb ’16
Reply to Reactive Extensions in Kernel
Porting the code for use in the kernel is going to be difficult. The kernel (or IOKit to be precise) uses a restricted subset of C++. Exceptions, multiple inheritance, templates and runtime type information (RTTI) are all disallowed. See Apple's IOKit Fundamentals document for information on these and other restriction you will face. A question you need to ask yourself is how much of your work actually needs to be done in the kernel. The general rule is to do the absolute minimum possible in the kernel since it is such a restricted environment.
Topic: App & System Services SubTopic: Drivers Tags:
Feb ’16
How can i work with relational data to particular Managed Objects?
I have an app which during start, is presented with a Table view controller and a navigation bar with an + button.So far i have this working well to the point where i can save and delete or edit these objects added to the table view. Each individual Item in this table view is selectable and acts like a folder to get a better picture.My problem is, how can i work on adding sub data to specific Parent folders?Sort of works like this graphic representation:Folder_one --> item1 item2Folder_two --> item1Folder_three --> item1 item2 item3 item4I managed to save the Folders on the Parent view controller and selecting one of them, would navigate to the selected folder's table view controller where the user is yet presented with another + button to add an item which stores data to that particular folder. The user can add as many as he/she wants but i cannot seem to work my way around or figure it out how it would work.My data model in Core Data is:Entity name: FolderAttributes: 'name' of type String ' tabColo
0
0
232
Feb ’16
Reply to Exact meaning of 'Super'
They are three different things that happen to use the same word super.1. The superclass of B is UIView (assuming you didn't actually declare B to be a subclass of A). This is a relationship between the classes.2. If you did '[anA addSubview: someB]', the superview of the instance of B is an instance of A. This is a relationship between instances of the classes.3. In '[super viewDidLoad]', 'super' means the same object as 'self', so the class of this 'super' is B. However, by using 'super', you're telling the compiler that you do not want to invoke class B's 'viewDidLoad' method, but its superclass's 'viewDidLoad'. That means UIView's viewDidLoad, not A's.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Feb ’16
Subclass implementing its own delegate protocol
Hey guys,is it OK for a subclass to implement its own delegate protocol? I have a subclass of UIScrollView which needs to respond to events like scrollViewDidEndDecelerating and scrollViewDidScroll. Therefore, I had to set the delegate property to self and implement the delegate methods inside the subclass. Nevertheless, other classes should still be able to receive these events too, as if they were using the superclass. For example, I want my subclass to do something special when the inherited scrollview ends scrolling, though the external delegate still needs to be informed about the event. Instances of the subclass and the subclass itself use the same delegate object/property. Is this even possible and would it be a safe approach or should the delegate used within the subclass get its own, private property? I appreciate any help you can provide!Cheers,Alex 🙂
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
5
Boosts
0
Views
3.2k
Activity
Feb ’16
Ways to 'persist' CloudKit data
The 'Designing for CloudKit' section of the iCloud Design Guide states that CloudKit is a service for moving data to and from iCloud and sharing data between users of your app. It’s your responsibility to convert model objects to records that you save using CloudKit, and to fetch changes made by other users and apply those changes to your model objects.Many CloudKit tutorials that I have followed don't make use of model objects. This results in data should the internet become unavailable. What is the best way to model objects and their relationships that fetch from CloudKit?
Replies
3
Boosts
0
Views
1.1k
Activity
Feb ’16
Reply to NSURLSessionDataTask vs NSURLSessionDownloadTask (NSURLSessionTaskState behavior)
You can illustrate this difference with much simpler code.var dataTask: NSURLSessionDataTask? var downloadTask: NSURLSessionDownloadTask? func dataTest() { let request = NSURLRequest(URL: NSURL(string: https://www.apple.com)!) self.dataTask = NSURLSession.sharedSession().dataTaskWithRequest(request) { (data, response, error) in print(self.dataTask!.state.rawValue) self.dataTask = nil } self.dataTask!.resume() } func downloadTest() { let request = NSURLRequest(URL: NSURL(string: https://www.apple.com)!) self.downloadTask = NSURLSession.sharedSession().downloadTaskWithRequest(request) { (fileURL, response, error) in print(self.downloadTask!.state.rawValue) self.downloadTask = nil } self.downloadTask!.resume() }dataTest() prints 3 ( .Completed) and downloadTest() prints 0 ( .Running). I’d call that a bug. The exact relationship between the completion block (or completion delegate callback) and the state property is not documented, but I think it’s reasonable to expect them to be consistent between the v
Replies
Boosts
Views
Activity
Feb ’16
Reply to Xcode 7.2.1 Breaks Swift & Objective-C Integration
I have a similar issue with Xcode 7.2.1. While my project still builds/runs as expected, I no longer get auto-completion, syntax highlighting, or ability to jump to definition for any symbol that is defined in Objective-C and used/referenced in Swift.For example, many of my view controllers are written in Swift and Xcode autocompletes/highlights/jumps to their own functions/properties without issue. However, functions/properties inherited from the common base class (written in Objective-C and imported via bridging header) do not auto-complete and are not syntax highlighted/can't find any definition to jump to. Building/running still works and I haven't observed any other issues. Objective-C files seem to have no issue (recognizing both Objective-C symbols as well as Swift symbols imported from MyProject-Swift.h)Interesting to note that the issue seems to go away when I clean the project. It only stops recognizing Objective-C symbols (inside Swift files) when I build/run the project and Xcode begins I
Replies
Boosts
Views
Activity
Feb ’16
Reply to Ways to 'persist' CloudKit data
>I don't understand this. Perhaps you can restate.A typo! When there is no internet available and the app is not loaded in memory, the data does not exist on the phone as there is no model for it to persist to! Currently, I am fetching CloudKit data and loading it straight in to a table view. I believe I need to have Swift classes representing each Record Type in CloudKit, and use subscriptions to check for changes in the data.An example:I have two record types: 'Specie' and 'Sighting'. In CloudKit, 'Sighting' has a 'specie' field of type Reference. This models the one-to-many relationship. I think I need to create a Specie.swift and a Sighting.swift class and fetch the CloudKit data from within these classes. Then, whenever there is no internet connection, the table view is still able to fetch the data persisted to my model. Specie records are read only so there would never be synch issues.Thanks!Edit: This extract from tuts+ Code sums up my point quite well: CloudKit doesn't offer local storage,
Replies
Boosts
Views
Activity
Feb ’16
Reply to Saving data structures
NSArray's writeToFile method looks very enticing. I could make the DerivationLine class inherit from NSObject. But again, it's the recursive part that I'm wondering how to handle.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’16
Reply to NSArrayController.add - how to get the result
First: stop flailing. Randomly trying different approaches just leads to more questions than answers, and muddies the waters.Second: understand that NSArrayController works. It's been around for a long time. It's easy, in situations like this, to get into the mindset that it's doing something weird. It's not.You can't understand NSArrayController without understanding something about KVO (key-value observing). In the 3-step sequence you tried, of course you got two entries in the table, because that's what you asked for. In step 1, you asked the array controller to add a new object to your data model for you. In step 2, you added a new object yourself. But because you didn't do that KVO-compliantly, you needed step 3 to cause the UI to update.Important: the array controller is not a container. It is a glue object (a mediating controller, if you want a MVC name for it) that handles certain aspects of the relationship between a data model and a UI element such as a table view. It pretends that it conta
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’16
Reply to getting this error message any help here?
It's fairly clear. Your storyboard has a scene (created by dragging a view controller onto the IB canvas some time in the past) which doesn't have any relationships (segues, containment, etc) with any other scene, nor is it marked as your storyboard's initial scene.It also has no identifier, so it can't be instantiated in code.In other words, the scene is unreachable — can never be used.If this is just some placeholder where you're keeping an unused piece of the UI, you don't have to do anything. Otherwise you need to figure out what the scene is supposed to be connected to.
Replies
Boosts
Views
Activity
Feb ’16
Reply to PacketTunnel - server down
I believe the lifecycle of your NEPacketTunnelProvider instance is completely in the control of the system. Same for the process in which your extension is running. Once you call cancelTunnelWithError: inside your extension and your stopTunnelWithReason:completionHandler: method is called inside your extension, the NEPacketTunnelProvider instance may be deinit'd at any time and the extension process may be terminated/killed at any time. In your containing app, assuming it's running (which you cannot guarantee AFAIK), you could set a timer when the tunnel stops and retry again when the timer expires.The docs are not exactly verbose, but I think the proper way to handle temporary and short networking issues that cause your tunnel to go down is to use the reasserting property inside your extension. The reasserting property is inherited from NETunnelProvider. So if your tunnel is disconnected because of a networking problem (e.g. the tunnel server severs the connection for any reason), you can set reasse
Replies
Boosts
Views
Activity
Feb ’16
iOS Enterprise App not from AppStore – any warranty issues?
We want to distribute a non-AppStore-app to our users over MDM (our users happen to be consumers rather than employees). As our users will have enrolled in our MDM service, their devices will already have established a trust relationship with us, so our app will already be trusted. Our app is not coming from the store, so it will not have been reviewed by Apple. A contact of mine told me that if a device has a non-AppStore-app installed, Apple may consider that device’s warranty to be void, and may refuse to repair it under warranty. It seems unlikely to me that that would be the case for enterprise apps delivered over MDM, but I would like to be sure. Can anyone verify that the Apple device warranty will still be valid when the device has a non-AppStore enterprise app delivered over MDM installed on it?
Replies
1
Boosts
0
Views
246
Activity
Feb ’16
Reply to Recursive enum 'Optional<Wrapped>' is not marked 'indirect'
Xcode stores information about your project in ~/Library/Developer/Xcode/DerivedData/ppp-hhh, where ppp is the project name and hhh is a hash of the path to the project (technically this is the workspace, not the project, but if you’re not using workspaces your projects have an embedded workspace so it ends up being the same thing). If you create a project with the same name in the same directory, these values end up being the same, so you inherit the derived data directory from your previous project. Normally this inherited derived data directory isn’t a problem. For example, with errors like this, once you successfully build the project, Xcode notices its mistake and cleans up. However, in some cases you will need to trash the problematic derived data directory. In that case it’s worthwhile filing a bug against Xcode because it really should deal with this stuff. Make sure you keep a copy of the derived data directory to attach to the bug.I see this all the time because I create a lot of t
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’16
Reply to Adding iCloud capability crashes Xcode
Thank you. Since my last post, I installed net.xxxx.foo2 onto my iPhone and iPad, and edited documents on one device and then the other device, watching them update via iCloud. Quite nice. I still don't know why net.xxxx.foo would not allow me to add the iCloud capabilities. The trail of clues may be too muddled at this point. Plus, I'm littering my Member Center with empty iCloud Containers while I thrash with different bundle IDs. (I see no way to delete useless iCloud Containers, so I guess they'll be my lifelong tatoos.) Seems to me that If I pursue this mystery any further, I should start fresh with a new project, and try to carefully reproduce my problem. Thanks bob133. If you have recommended reading that helps me understand the relationships between App ID, bundle identifier, product name, etc ... let me know.
Replies
Boosts
Views
Activity
Feb ’16
Reply to Reactive Extensions in Kernel
Porting the code for use in the kernel is going to be difficult. The kernel (or IOKit to be precise) uses a restricted subset of C++. Exceptions, multiple inheritance, templates and runtime type information (RTTI) are all disallowed. See Apple's IOKit Fundamentals document for information on these and other restriction you will face. A question you need to ask yourself is how much of your work actually needs to be done in the kernel. The general rule is to do the absolute minimum possible in the kernel since it is such a restricted environment.
Topic: App & System Services SubTopic: Drivers Tags:
Replies
Boosts
Views
Activity
Feb ’16
How can i work with relational data to particular Managed Objects?
I have an app which during start, is presented with a Table view controller and a navigation bar with an + button.So far i have this working well to the point where i can save and delete or edit these objects added to the table view. Each individual Item in this table view is selectable and acts like a folder to get a better picture.My problem is, how can i work on adding sub data to specific Parent folders?Sort of works like this graphic representation:Folder_one --> item1 item2Folder_two --> item1Folder_three --> item1 item2 item3 item4I managed to save the Folders on the Parent view controller and selecting one of them, would navigate to the selected folder's table view controller where the user is yet presented with another + button to add an item which stores data to that particular folder. The user can add as many as he/she wants but i cannot seem to work my way around or figure it out how it would work.My data model in Core Data is:Entity name: FolderAttributes: 'name' of type String ' tabColo
Replies
0
Boosts
0
Views
232
Activity
Feb ’16