Search results for

“SwiftData inheritance relationship”

4,982 results found

Post

Replies

Boosts

Views

Activity

multiple persistent stores, can I have one for each entity?
for years, I have avoided CD for this particular project.but I need spotlight support, and There seems to be only 1 way to get it these days: use core data. It wasn't always this way, and in my first release, I was able to find multiple 3rd party walkthroughs for getting spotlight support up and running. Those tutorials no longer work, and some of them no longer have any context. so my application is NOT a good fit for CD, but I am trying to determine if I can make it work, because spotlight is a requirement, and there seems to be no other path to spotlight.My first hurdle is persistent stores, can I have 1 persistent store Per entity?I know that this is a strange question. I don't want to ask it, I would rather just build the spotlight plugin myself. This however, is not an option. Apparently guessing how to do something, doesn't just make it work.I need to save files, and those individual files need to have spotlight metadata in them, such that when the user does a spotlight search, he finds the individual
9
0
1.3k
Jan ’16
Reply to multiple persistent stores, can I have one for each entity?
When you set up a CoreData runtime environment, you can configure it so that it uses multiple persistent stores and could go as far as having one entity type per store. Doing so would cause some difficulties if you wanted any relationships between the entities.If you're talking about One and only one entity per persistent store, that's essentially I want to create a bunch of different databases, each with one table with one row in them. And, that's why you don't see anyone explaining how to do it.Do you understand how to create a persistent store and how to create an entity in that persistent store?On the other hand, should you be asking about how to use CoreSpotlight instead?https://developer.apple.com/library/ios/documentation/General/Conceptual/AppSearch/AppContent.htmlor about Spotlight on the Mac?https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Conceptual/MetadataIntro/MetadataIntro.html#//apple_ref/doc/uid/TP40001280-BBCFBCAGFor the record, I vaguely remember the Spotligh
Jan ’16
enum cannot conform to protocol
Several days earlier I worte the code,I imported the library of Alamofire.I defined one enum,let it confirm to StringConvertible protocol.But the error told me enum cannot StringConvertible protocol.Actually Struct,enum and class both can conform to protocols.I confirmed the issue,possibly it has relationship with Xcode.My version of Xcode is 7.2...Hope later modify the bug of Xcode.
3
0
1.3k
Jan ’16
Reply to How to implement NSTextFinderClient protocol in NSTextView in Swift?
Thanks. With showing some code, someone without experience of using NSTextFinderClient would help solving the issue.As you already know, NSTextView inherits this property from NSText: public var string: String?And in NSTextFinderClient, a property of the same name `string` is declared as: optional public var string: String { get }An optional property with non-optional type... So confusing, but it actually has different optionality.I'm not sure this is sort of a mistake and should-be-fixed issue, but one sure thing is that you cannot make NSTextView conform to NSTextFinderClient with the current SDK in Swift.I couldn't find a quick workaround and you may need to make some other class conforming the needed protocol:class MyTextFinderClient: NSObject, NSTextFinderClient { weak var textView: NSTextView? init(textView: NSTextView) { self.textView = textView } var string: String {return textView?.string ?? } //... }
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
Reply to DidSet on properties of type Array
I'm under the impression that because the Swift team doesn't believe in non-final classes, this weird stuff will happen if the classes are not final, more often, because subclassable things are not put through their paces as much. This may not be true, at all, but I kind of hope it is because I despise inheritance but love protocol extensions and if Apple isn't doing a good job maintaining inheritance, people will stop using it even though they think they want to use it.I only discovered this weird workaround due to my brain seeing a lack of the final keyword and subsequently forcing it into existence through my fingers. I hoped that because I only like final classes, it would be a solution, magically. That that actually happened was quite a surprise to me. 😁
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’16
Core Data, NSFetchedResultsController, BAD_ACCESS bug
Hello,I've been working on this error for a couple of days now and I havn't been able to figure it out. I have a one to many relationship (days have many events) and they're both displayed using two NSFetchedResultsControllers in subsequent tableViewControllers (firstTVC and secondTVC). There is a third view controller that I use to add the events to the days. When I add only the first event on a day (in the thirdVC) the console reads:*** Assertion failure in -[UITableView _endCellAnimationsWithContext:]CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to delete row 0 from section 0 which only contains 0 rows before the update with userInfoAfter logging a bunch I found that the controllerDidChangeContent was called in both the FirstTVC and the SecondTVC and the error logs right after this method is called in the SecondTVC.Then I go back to the secondTVC from the thirdVC and the tab
1
0
519
Jan ’16
Protocol Inheritance - Function Type Override
I would like a 'child' protocol to override the types of one of the 'parent' functions. Like this:protocol Delegate {} protocol Thing { func handle (delegate: Delegate) } protocol OtherDelegate : Delegate {} protocol OtherThing : Thing { func handle (delegate: OtherDelegate) // requires OtherDelegate, not Delegate }If I then implement `OtherThing` with:class StandardOtherThing : OtherThing { // ... }It requires implementations of two `handle` functions - one for `Delegate` and one for `OtherDelegate`. It should be an error to pass `OtherThing` just a plain old `Delegate`; `OtherDelegate` is required. Can't I catch this before runtime?If instead I try parameterizing `handle` asprotocol Thing { func handle<D: Delegate> (delegate: D) } protocol OtherThing : Thing { func handle<D: OtherDelegate> (delegate: D) }still no dice, the `OtherThing` requires two methods.I know that I can use:protocol Entity { typealias D : Delegate func handle (delegate: D) } protocol OtherEntity : Entity { typealias D : Othe
1
0
443
Jan ’16
Inherit static library into appdlegate
We are trying to integrate an SDK developed in Objective C to iOS app developed in Swift. The SDK’s static library is inherited into App delegate class. Is this an accepted standard per Apple guidelines ? I wanted o check the same to avoid app rejection on submission to store.Eg : AppDelgate.swiftclass AppDelegate : MystaticLibrary,UIApplicationDelegate { //My code }MystaticLibrary-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { //My Code }Thanks in advance!RegardsVignesh B RiOS Developer
0
0
245
Jan ’16
Reply to initWithPasteboardPropertyList from Objc to swift
>> Well, but this initializer irequired to conform to protocol 'NSPasteboardReading'...In that case you need both: a factory method (to get the object to be of the correct class) and an initializer to satisfy the protocol. The initializer part is essentially trivial, except that you have to have all the classes implement it, and that means you negotiate the init inheritance rules, and what's inherited depends on what other init each class implements. So, you might have to add some boilerplate inits that simply call through to super. It's tedious to satisfy the compiler, but not inherently complicated.I fear it's the whole architecture of my code that needs redesign !That's another approach. 🙂 The style of this code is very Obj-C ( old-fashioned Obj-C at that), and a re-imagining in Swift terms would be excellent.
Topic: Programming Languages SubTopic: Swift Tags:
Feb ’16
Data integrity when deleting objects with ordered many-to-many relationships?
I have a problem deleting objects that have ordered, many-to-many relationships.Simplified model:Container.items (ordered, Nullify) <<-->> Item.containers (Nullify)Container.image (Cascade) <-> Image.containerConsider a single container with two items, already saved. Delete the container. Search for all items that have no container, i.e.: containers.@count == 0. Performing a fetch returns no objects.In contrast, search for containers.@count == 1. Returns both items. Then inspect those items, and they have no containers. Inspect the database, and the join table still has entries which refer to containers that do not exist.When I change the relationship to make it unordered, the problem goes away.I have seen various problems reported with ordered relationships on Stack Overflow. So this may be related. However, in a sample project, I am unable to reproduce the issue.Is there some way I can (indirectly) force those join entries to go away? What could I be doing wrong that woul
1
0
354
Feb ’16
core data app does not load saved data.
weird problem.wrote a core data app, worked great, until last week. Now it doesn't load any data.the save files, (binary) seem to be intact (based on file sizes)but when the file is loaded, there's nothing in the document window. I know. it sounds stupid. It sounds stupid to say it.I can add objects, work with them, and save files. the files get saved with the data intact. Opening those files produces an empty document. I have not overridden ANY app level methods. I literally do not have any of the loading or saving code IN my app at all... it's all inherited. the data model consists Of a single entity, which has 0 relationships, and 4 String properties.bindings all work flawlessly...and the kicker:the app worked just fine until a few days ago (OS update, is what i'm thinking controlled the timing) saving, opening, everything worked. No changes, no Compiles. It just stopped working. but other Core data apps work just fine. I tried looking at my code.... but there's little or no Code, and not
1
0
475
Feb ’16
Reply to PacketTunnelProvider - Packetflow
Check out the PacketTunnelProvider class in the SimpleTunnel sample code. It uses the packetFlow property (inherited from the NEPacketTunnelProvider superclass) to get packets coming from higher levels in the OS and return packets back up to those higher levels. This is where you need to connect your C code. The sample code does this work using a helper class, ClientTunnelConnection, but there’s just a convenience. Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Feb ’16
Reply to Auto Layout.
Have you tried manually adding anything that seems to be missing? (Control-drag between elements, then select the relationship you'd like to set up.)
Replies
Boosts
Views
Activity
Jan ’16
multiple persistent stores, can I have one for each entity?
for years, I have avoided CD for this particular project.but I need spotlight support, and There seems to be only 1 way to get it these days: use core data. It wasn't always this way, and in my first release, I was able to find multiple 3rd party walkthroughs for getting spotlight support up and running. Those tutorials no longer work, and some of them no longer have any context. so my application is NOT a good fit for CD, but I am trying to determine if I can make it work, because spotlight is a requirement, and there seems to be no other path to spotlight.My first hurdle is persistent stores, can I have 1 persistent store Per entity?I know that this is a strange question. I don't want to ask it, I would rather just build the spotlight plugin myself. This however, is not an option. Apparently guessing how to do something, doesn't just make it work.I need to save files, and those individual files need to have spotlight metadata in them, such that when the user does a spotlight search, he finds the individual
Replies
9
Boosts
0
Views
1.3k
Activity
Jan ’16
Reply to multiple persistent stores, can I have one for each entity?
When you set up a CoreData runtime environment, you can configure it so that it uses multiple persistent stores and could go as far as having one entity type per store. Doing so would cause some difficulties if you wanted any relationships between the entities.If you're talking about One and only one entity per persistent store, that's essentially I want to create a bunch of different databases, each with one table with one row in them. And, that's why you don't see anyone explaining how to do it.Do you understand how to create a persistent store and how to create an entity in that persistent store?On the other hand, should you be asking about how to use CoreSpotlight instead?https://developer.apple.com/library/ios/documentation/General/Conceptual/AppSearch/AppContent.htmlor about Spotlight on the Mac?https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Conceptual/MetadataIntro/MetadataIntro.html#//apple_ref/doc/uid/TP40001280-BBCFBCAGFor the record, I vaguely remember the Spotligh
Replies
Boosts
Views
Activity
Jan ’16
enum cannot conform to protocol
Several days earlier I worte the code,I imported the library of Alamofire.I defined one enum,let it confirm to StringConvertible protocol.But the error told me enum cannot StringConvertible protocol.Actually Struct,enum and class both can conform to protocols.I confirmed the issue,possibly it has relationship with Xcode.My version of Xcode is 7.2...Hope later modify the bug of Xcode.
Replies
3
Boosts
0
Views
1.3k
Activity
Jan ’16
Reply to How to implement NSTextFinderClient protocol in NSTextView in Swift?
Thanks. With showing some code, someone without experience of using NSTextFinderClient would help solving the issue.As you already know, NSTextView inherits this property from NSText: public var string: String?And in NSTextFinderClient, a property of the same name `string` is declared as: optional public var string: String { get }An optional property with non-optional type... So confusing, but it actually has different optionality.I'm not sure this is sort of a mistake and should-be-fixed issue, but one sure thing is that you cannot make NSTextView conform to NSTextFinderClient with the current SDK in Swift.I couldn't find a quick workaround and you may need to make some other class conforming the needed protocol:class MyTextFinderClient: NSObject, NSTextFinderClient { weak var textView: NSTextView? init(textView: NSTextView) { self.textView = textView } var string: String {return textView?.string ?? } //... }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
Reply to Xcode 3.2 swift shows error with the convenient initializer
What class do you try to inherit?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
Reply to DidSet on properties of type Array
I'm under the impression that because the Swift team doesn't believe in non-final classes, this weird stuff will happen if the classes are not final, more often, because subclassable things are not put through their paces as much. This may not be true, at all, but I kind of hope it is because I despise inheritance but love protocol extensions and if Apple isn't doing a good job maintaining inheritance, people will stop using it even though they think they want to use it.I only discovered this weird workaround due to my brain seeing a lack of the final keyword and subsequently forcing it into existence through my fingers. I hoped that because I only like final classes, it would be a solution, magically. That that actually happened was quite a surprise to me. 😁
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’16
Core Data, NSFetchedResultsController, BAD_ACCESS bug
Hello,I've been working on this error for a couple of days now and I havn't been able to figure it out. I have a one to many relationship (days have many events) and they're both displayed using two NSFetchedResultsControllers in subsequent tableViewControllers (firstTVC and secondTVC). There is a third view controller that I use to add the events to the days. When I add only the first event on a day (in the thirdVC) the console reads:*** Assertion failure in -[UITableView _endCellAnimationsWithContext:]CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to delete row 0 from section 0 which only contains 0 rows before the update with userInfoAfter logging a bunch I found that the controllerDidChangeContent was called in both the FirstTVC and the SecondTVC and the error logs right after this method is called in the SecondTVC.Then I go back to the secondTVC from the thirdVC and the tab
Replies
1
Boosts
0
Views
519
Activity
Jan ’16
Protocol Inheritance - Function Type Override
I would like a 'child' protocol to override the types of one of the 'parent' functions. Like this:protocol Delegate {} protocol Thing { func handle (delegate: Delegate) } protocol OtherDelegate : Delegate {} protocol OtherThing : Thing { func handle (delegate: OtherDelegate) // requires OtherDelegate, not Delegate }If I then implement `OtherThing` with:class StandardOtherThing : OtherThing { // ... }It requires implementations of two `handle` functions - one for `Delegate` and one for `OtherDelegate`. It should be an error to pass `OtherThing` just a plain old `Delegate`; `OtherDelegate` is required. Can't I catch this before runtime?If instead I try parameterizing `handle` asprotocol Thing { func handle<D: Delegate> (delegate: D) } protocol OtherThing : Thing { func handle<D: OtherDelegate> (delegate: D) }still no dice, the `OtherThing` requires two methods.I know that I can use:protocol Entity { typealias D : Delegate func handle (delegate: D) } protocol OtherEntity : Entity { typealias D : Othe
Replies
1
Boosts
0
Views
443
Activity
Jan ’16
Inherit static library into appdlegate
We are trying to integrate an SDK developed in Objective C to iOS app developed in Swift. The SDK’s static library is inherited into App delegate class. Is this an accepted standard per Apple guidelines ? I wanted o check the same to avoid app rejection on submission to store.Eg : AppDelgate.swiftclass AppDelegate : MystaticLibrary,UIApplicationDelegate { //My code }MystaticLibrary-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { //My Code }Thanks in advance!RegardsVignesh B RiOS Developer
Replies
0
Boosts
0
Views
245
Activity
Jan ’16
Reply to initWithPasteboardPropertyList from Objc to swift
>> Well, but this initializer irequired to conform to protocol 'NSPasteboardReading'...In that case you need both: a factory method (to get the object to be of the correct class) and an initializer to satisfy the protocol. The initializer part is essentially trivial, except that you have to have all the classes implement it, and that means you negotiate the init inheritance rules, and what's inherited depends on what other init each class implements. So, you might have to add some boilerplate inits that simply call through to super. It's tedious to satisfy the compiler, but not inherently complicated.I fear it's the whole architecture of my code that needs redesign !That's another approach. 🙂 The style of this code is very Obj-C ( old-fashioned Obj-C at that), and a re-imagining in Swift terms would be excellent.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Feb ’16
Data integrity when deleting objects with ordered many-to-many relationships?
I have a problem deleting objects that have ordered, many-to-many relationships.Simplified model:Container.items (ordered, Nullify) <<-->> Item.containers (Nullify)Container.image (Cascade) <-> Image.containerConsider a single container with two items, already saved. Delete the container. Search for all items that have no container, i.e.: containers.@count == 0. Performing a fetch returns no objects.In contrast, search for containers.@count == 1. Returns both items. Then inspect those items, and they have no containers. Inspect the database, and the join table still has entries which refer to containers that do not exist.When I change the relationship to make it unordered, the problem goes away.I have seen various problems reported with ordered relationships on Stack Overflow. So this may be related. However, in a sample project, I am unable to reproduce the issue.Is there some way I can (indirectly) force those join entries to go away? What could I be doing wrong that woul
Replies
1
Boosts
0
Views
354
Activity
Feb ’16
XCode Version 7.2.1 (7C1002) use segues line .... exit
XCode Version 7.2.1 (7C1002)1. use storyboard2. create Tab Bar Controller3. create View Controller4. Presenting Segues (relationship +) .......Xcode exit.......
Replies
0
Boosts
0
Views
253
Activity
Feb ’16
core data app does not load saved data.
weird problem.wrote a core data app, worked great, until last week. Now it doesn't load any data.the save files, (binary) seem to be intact (based on file sizes)but when the file is loaded, there's nothing in the document window. I know. it sounds stupid. It sounds stupid to say it.I can add objects, work with them, and save files. the files get saved with the data intact. Opening those files produces an empty document. I have not overridden ANY app level methods. I literally do not have any of the loading or saving code IN my app at all... it's all inherited. the data model consists Of a single entity, which has 0 relationships, and 4 String properties.bindings all work flawlessly...and the kicker:the app worked just fine until a few days ago (OS update, is what i'm thinking controlled the timing) saving, opening, everything worked. No changes, no Compiles. It just stopped working. but other Core data apps work just fine. I tried looking at my code.... but there's little or no Code, and not
Replies
1
Boosts
0
Views
475
Activity
Feb ’16
Reply to PacketTunnelProvider - Packetflow
Check out the PacketTunnelProvider class in the SimpleTunnel sample code. It uses the packetFlow property (inherited from the NEPacketTunnelProvider superclass) to get packets coming from higher levels in the OS and return packets back up to those higher levels. This is where you need to connect your C code. The sample code does this work using a helper class, ClientTunnelConnection, but there’s just a convenience. Share and Enjoy — Quinn “The Eskimo!” Apple Developer Relations, Developer Technical Support, Core OS/Hardware let myEmail = eskimo + 1 + @apple.com
Replies
Boosts
Views
Activity
Feb ’16