Search results for

“SwiftData inheritance relationship”

4,986 results found

Post

Replies

Boosts

Views

Activity

Compound AND predicate for many to many relationship using SUBQUERY
I have an entity A with a many to many relationship events with entity Event. Entity Event has an attribute eventName.I want to be able to fetch all entity As that have a given set of Event entitys that match the entityName selected by the user. For an ANY fetch, a compound OR predicate works fine. But for an ALL fetch (where only entity As that have ALL of the user chosen events will be fetched) the compound AND predicate returns a nil!I was told that I would have to use subqueries. My deliema is that I am having a hard time figuring out how to form a subquery string.The format is as follows...SUBQUERY(collection_expression, variable_expression, predicate);I'll have the eventName string selected by the user so that is dynamic. So what should my subquery look like if I want to use the LIKE[d] operator?the collection_expression would be the relationship events if i am not wrong?kindly help me out with this.thankyou.
8
0
2.5k
Jun ’15
Reply to Compound AND predicate for many to many relationship using SUBQUERY
I'm pretty sure you can't actually have a string value that matches two LIKE clauses like that without specify a wildcard in both of them.Because you're expected to supply the wildcards:LIKE The left hand expression equals the right-hand expression: ? and * are allowed as wildcard characters, where ? matches 1 character and * matches 0 or more characters. In other words, if you're trying to match Birthday party you need soething like Birthday* and *party as your two target values, or *birthday* and *party*.More importantly, if you're trying to make sure the same event matches both Birthday* and *party then you needSUBQUERY(event, $x, $x.event LIKE[d] Birthday* && $x.event LIKE[d] *party).@count > 0That's the more common use for subquery, by the way. When you have one of the objects in the event to-many relationship and you want to make sure that the same object satisfies multiple criteria.The way you have it specified it,SUBQUERY(event, $x, $x.event LIKE[d] Birthday*).@count > 0 AND SUB
Jun ’15
Reply to Accessing CoreData asynchronously from the UI and with Networking
I'm not sure if you're realizing the fact that every single attribute or relationship access (read or write) on a managed object (along with most of the managed object methods) are also an operation that needs to be subject to proper thread safety procedures.dispatch_sync and dispatch_barrier aren't the distinction that you're looking for, because accessing new attribute values are just as likely to cause state changes in the managed object and the managed object context as write values are. Because the first access of an attribute value may end up bringing it into memory or the first access may end up accessing a pre-loaded value.
Jun ’15
Reply to ld: warning: directory not found
Found something when comparing a new project vs an older one...In the old project, the warning was only being produced by the test target of my projects. Under 'Search Paths', I found it was including two items under 'Framework Search Paths':$(SDKROOT)/Developer/Library/Frameworks$(inherited)The new project kept the 'Framework Search Paths' empty.Deleting those entries in my older project then removed the warning.Note: I have not exhaustively compared settings, so there may be additional differences.
Jun ’15
Reply to ld: warning: directory not found
The Solution from rsharb is right !You only have to go unter your Project to Targets TestsSearch PathsFramework Search Pathsand delete $(SDKROOT)/Developer/Library/Frameworksthe other one $(inherited) you can keepThat is the step by step Solution .It worked for me fine . I hope I works for you too.With best regards PhilippThanks to rsharb for the solution .
Jun ’15
Xcode 7 crashes when opening Swift iBook playground in El Capitan
Hello,When I attempt to open the Guided Tour playground file mentioned in the pre-release Swift programming book in Xcode 7 on El Capitan (first build), Xcode crashes immediately upon opening. I've been able to use it fine with other projects/playgrounds etc, its just this indiviudal one.I've included a snippet of the crash log - does anyone know of a fix for this?Thanks in advance.Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Application Specific Information: ProductBuildVersion: 7A120f ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDELanguageSupport/IDELanguageSupport-8102.19/IDELanguageSupportUI/Playground/Editor/IDEPlaygroundSourceTextScrollView.m:322 Details: result should be an instance inheriting from IDEPlaygroundTextView, but it is nil Object: <IDEPlaygroundSourceTextScrollView: 0x7f8ffd8cebc0> Method: -_drawGutterAndResultSidebarBackgroun
0
0
230
Jun ’15
Can you create a Set of a single protocol?
I'm wondering, is it even possible to create a `Set` in Swift whose members are guaranteed only to share conformance to a Protocol?My initial attempt looked like this:protocol MyProtocol {} var mySet: Set<MyProtocol> = []But that yields the compiler error Type 'MyProtocol' does not conform to protocol 'Hashable'.Next I tried:protocol MyProtocol: Hashable { } var mySet: Set<MyProtocol> = []But now we get the error Protocol 'MyProtocol' can only be used as a generic constraint because it has Self or associated type requirementsClearly we've hit a problem with the Swift distinction between static and dynamic protocols that prevents us from using a Hashable protocol as a type parameter (because Hashable is Equatable, and Equatable for some reason requires that you're trying to equate a class to itself).What if we try adding Hashable compliance to MyProtocol via an extension?protocol MyProtocol {} extension MyProtocol: Hashable {}Extension of protocol 'MyProtocol' cannot have an inheritance cl
18
0
9.4k
Jun ’15
Reachability Invalid Binary
Today when I attempted to upload the binary for my app I recieved an Invalid Binary message.Non-public API usage:The app contains or inherits from non-public classes in cbe-mobile: ReachabilityI had been using Reachbility 3.0, but with the error I upgraded to Reachability 3.5 as found at https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.htmlUpon resubmission the error persists (addiontally the Xcode Validation system does not detect any issues). What private API is being used and how can I change it?
1
0
434
Jun ’15
Reply to Can you create a Set of a single protocol?
Hashable inherits from Equatable because hash values are typically used as a shortcut to speed up identifying potentially equal items.It's functionality added on to Equatable to make equality checking faster (by limiting the pool of items that need the full equality comparison). But since the hash value is typically smaller than the object it was generated from, there are conflicts and equality can't be determined from equal hash values alone.If Hashable didn't inherit from Equatable, pretty much everything that used a Hashable type would need to be updated to require Hashable & Equatable anyway.Equatable is defined in terms of Self, because otherwise there wouldn't be any way to identify/enforce the parameter types for the required function.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
how to reset/restart an animation and have it appear continuous?
So, I am fairly new to iOS programming, and have inherited a project from a former coworker. We are building an app that contains a gauge UI. When data comes in, we want to smoothly rotate our layer (which is a needle image) from the current angle to a new target angle. Here is what we have, which worked well with slow data: -(void) MoveNeedleToAngle:(float) target { static float old_Value = 0.0; CABasicAnimation *rotateCurrentPressureTick = [CABasicAnimation animationWithKeyPath:@transform.rotation); [rotateCurrentPressureTick setDelegate:self]; rotateCurrentPressureTick.fromValue = [NSSNumber numberWithFloat:old_value/57.2958]; rotateCurrentPressureTick.removedOnCompletion=NO; rotateCurrentPressureTick.fillMode=kCAFillModeForwards; rotateCurrentPressureTick.toValue=[NSSNumber numberWithFloat:target/57.2958]; rotateCurrentPressureTick.duration=3; // constant 3 second sweep [imageView_Needle.layer addAnimation:rotateCurrentPressureTick forKey:@rotateTick]; old_Value = target; }The problem is we have
2
0
4.4k
Jun ’15
Reply to Abort trap: 6
@LCS, yes, I do have many subclasses of Objective-C classes. But it's a SceneKit app where just about every object, including my custom classes, are derived from a SceneKit Objective-C object, like SCNNode (which inherits from NSObject), so it's pretty much impossible for me to test by removing those objects.I did try removing all overrides of Objective-C computed properties (override var ...) as suggested above, but it did not help.I also have quite a few extensions and some global utility functions, many of which extend or operate on Obj-C objects or structs. But again, removing those would totally break my app and generate a thousand errors (before Abort trap: 6 gets hit), so I can't test it.
Jun ’15
Reply to Will generics still be useful now that there are protocol extensions?
Multiple inheritance isn't supported in ObjC or Swift, but that doesn't mean it's impossible in OOP; C++ has supported multiple inheritance for a LONG time.Anyhow, you missed my point.Generics allow you to constrain to specific, homogeneous types.func foo<T>(items: [T]) { ... }Items must be an array made up of items of T.func foo(items: [T]) { ... }If T is a protocol, then items can be an array made up of anything that conforms to T. This was talked about in the talk when walking through the historical issues with OOP.Another example where the combination of protocol extensions and a generic type system really compliment one another:extension Equatable where Self : Drawable { func isEqualTo(other: Drawable) -> Bool { guard let o = other as? Self else { return false } return self == o } }That protocol extension is not possible to write without generics.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’15
Compound AND predicate for many to many relationship using SUBQUERY
I have an entity A with a many to many relationship events with entity Event. Entity Event has an attribute eventName.I want to be able to fetch all entity As that have a given set of Event entitys that match the entityName selected by the user. For an ANY fetch, a compound OR predicate works fine. But for an ALL fetch (where only entity As that have ALL of the user chosen events will be fetched) the compound AND predicate returns a nil!I was told that I would have to use subqueries. My deliema is that I am having a hard time figuring out how to form a subquery string.The format is as follows...SUBQUERY(collection_expression, variable_expression, predicate);I'll have the eventName string selected by the user so that is dynamic. So what should my subquery look like if I want to use the LIKE[d] operator?the collection_expression would be the relationship events if i am not wrong?kindly help me out with this.thankyou.
Replies
8
Boosts
0
Views
2.5k
Activity
Jun ’15
Reply to Compound AND predicate for many to many relationship using SUBQUERY
I'm pretty sure you can't actually have a string value that matches two LIKE clauses like that without specify a wildcard in both of them.Because you're expected to supply the wildcards:LIKE The left hand expression equals the right-hand expression: ? and * are allowed as wildcard characters, where ? matches 1 character and * matches 0 or more characters. In other words, if you're trying to match Birthday party you need soething like Birthday* and *party as your two target values, or *birthday* and *party*.More importantly, if you're trying to make sure the same event matches both Birthday* and *party then you needSUBQUERY(event, $x, $x.event LIKE[d] Birthday* && $x.event LIKE[d] *party).@count > 0That's the more common use for subquery, by the way. When you have one of the objects in the event to-many relationship and you want to make sure that the same object satisfies multiple criteria.The way you have it specified it,SUBQUERY(event, $x, $x.event LIKE[d] Birthday*).@count > 0 AND SUB
Replies
Boosts
Views
Activity
Jun ’15
Reply to Accessing CoreData asynchronously from the UI and with Networking
I'm not sure if you're realizing the fact that every single attribute or relationship access (read or write) on a managed object (along with most of the managed object methods) are also an operation that needs to be subject to proper thread safety procedures.dispatch_sync and dispatch_barrier aren't the distinction that you're looking for, because accessing new attribute values are just as likely to cause state changes in the managed object and the managed object context as write values are. Because the first access of an attribute value may end up bringing it into memory or the first access may end up accessing a pre-loaded value.
Replies
Boosts
Views
Activity
Jun ’15
Reply to ld: warning: directory not found
Found something when comparing a new project vs an older one...In the old project, the warning was only being produced by the test target of my projects. Under 'Search Paths', I found it was including two items under 'Framework Search Paths':$(SDKROOT)/Developer/Library/Frameworks$(inherited)The new project kept the 'Framework Search Paths' empty.Deleting those entries in my older project then removed the warning.Note: I have not exhaustively compared settings, so there may be additional differences.
Replies
Boosts
Views
Activity
Jun ’15
Reply to ld: warning: directory not found
The Solution from rsharb is right !You only have to go unter your Project to Targets TestsSearch PathsFramework Search Pathsand delete $(SDKROOT)/Developer/Library/Frameworksthe other one $(inherited) you can keepThat is the step by step Solution .It worked for me fine . I hope I works for you too.With best regards PhilippThanks to rsharb for the solution .
Replies
Boosts
Views
Activity
Jun ’15
Xcode 7 crashes when opening Swift iBook playground in El Capitan
Hello,When I attempt to open the Guided Tour playground file mentioned in the pre-release Swift programming book in Xcode 7 on El Capitan (first build), Xcode crashes immediately upon opening. I've been able to use it fine with other projects/playgrounds etc, its just this indiviudal one.I've included a snippet of the crash log - does anyone know of a fix for this?Thanks in advance.Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Application Specific Information: ProductBuildVersion: 7A120f ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDELanguageSupport/IDELanguageSupport-8102.19/IDELanguageSupportUI/Playground/Editor/IDEPlaygroundSourceTextScrollView.m:322 Details: result should be an instance inheriting from IDEPlaygroundTextView, but it is nil Object: <IDEPlaygroundSourceTextScrollView: 0x7f8ffd8cebc0> Method: -_drawGutterAndResultSidebarBackgroun
Replies
0
Boosts
0
Views
230
Activity
Jun ’15
Can you create a Set of a single protocol?
I'm wondering, is it even possible to create a `Set` in Swift whose members are guaranteed only to share conformance to a Protocol?My initial attempt looked like this:protocol MyProtocol {} var mySet: Set<MyProtocol> = []But that yields the compiler error Type 'MyProtocol' does not conform to protocol 'Hashable'.Next I tried:protocol MyProtocol: Hashable { } var mySet: Set<MyProtocol> = []But now we get the error Protocol 'MyProtocol' can only be used as a generic constraint because it has Self or associated type requirementsClearly we've hit a problem with the Swift distinction between static and dynamic protocols that prevents us from using a Hashable protocol as a type parameter (because Hashable is Equatable, and Equatable for some reason requires that you're trying to equate a class to itself).What if we try adding Hashable compliance to MyProtocol via an extension?protocol MyProtocol {} extension MyProtocol: Hashable {}Extension of protocol 'MyProtocol' cannot have an inheritance cl
Replies
18
Boosts
0
Views
9.4k
Activity
Jun ’15
Reachability Invalid Binary
Today when I attempted to upload the binary for my app I recieved an Invalid Binary message.Non-public API usage:The app contains or inherits from non-public classes in cbe-mobile: ReachabilityI had been using Reachbility 3.0, but with the error I upgraded to Reachability 3.5 as found at https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.htmlUpon resubmission the error persists (addiontally the Xcode Validation system does not detect any issues). What private API is being used and how can I change it?
Replies
1
Boosts
0
Views
434
Activity
Jun ’15
Reply to Can you create a Set of a single protocol?
Hashable inherits from Equatable because hash values are typically used as a shortcut to speed up identifying potentially equal items.It's functionality added on to Equatable to make equality checking faster (by limiting the pool of items that need the full equality comparison). But since the hash value is typically smaller than the object it was generated from, there are conflicts and equality can't be determined from equal hash values alone.If Hashable didn't inherit from Equatable, pretty much everything that used a Hashable type would need to be updated to require Hashable & Equatable anyway.Equatable is defined in terms of Self, because otherwise there wouldn't be any way to identify/enforce the parameter types for the required function.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’15
Are Game Center friend relationships supposed to be private? What if scores on a leaderboard allow anyone to infer some friend relationships with high probability? Would this result in app rejection by Apple?
The reason this would happen is because I am thinking of modifying scores before submitting them to Game Center by adding to them scores of the player's friends from the last day.
Replies
0
Boosts
0
Views
112
Activity
Jun ’15
Reply to Accessing CoreData asynchronously from the UI and with Networking
I did not know until now that an attribute or relationship might not be initialized after fetching an object. Thank you for pointing this out.Between 1b and 1c: What if I convert all fetched objects into immutable copies and pass them over to the UI?Is this approach better or are there better solutions?
Replies
Boosts
Views
Activity
Jun ’15
how to reset/restart an animation and have it appear continuous?
So, I am fairly new to iOS programming, and have inherited a project from a former coworker. We are building an app that contains a gauge UI. When data comes in, we want to smoothly rotate our layer (which is a needle image) from the current angle to a new target angle. Here is what we have, which worked well with slow data: -(void) MoveNeedleToAngle:(float) target { static float old_Value = 0.0; CABasicAnimation *rotateCurrentPressureTick = [CABasicAnimation animationWithKeyPath:@transform.rotation); [rotateCurrentPressureTick setDelegate:self]; rotateCurrentPressureTick.fromValue = [NSSNumber numberWithFloat:old_value/57.2958]; rotateCurrentPressureTick.removedOnCompletion=NO; rotateCurrentPressureTick.fillMode=kCAFillModeForwards; rotateCurrentPressureTick.toValue=[NSSNumber numberWithFloat:target/57.2958]; rotateCurrentPressureTick.duration=3; // constant 3 second sweep [imageView_Needle.layer addAnimation:rotateCurrentPressureTick forKey:@rotateTick]; old_Value = target; }The problem is we have
Replies
2
Boosts
0
Views
4.4k
Activity
Jun ’15
Reply to Will generics still be useful now that there are protocol extensions?
Protocol extensions are extremly powerful without generics!They allow to do what was impossible in OOP: kind of multiple inheritance. And, as they are presented in the session 'Protocol Oriented Programing' (excellent session btw), they even open up a new paradigm. I suggest you check it out, it's really a blast.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’15
Reply to Abort trap: 6
@LCS, yes, I do have many subclasses of Objective-C classes. But it's a SceneKit app where just about every object, including my custom classes, are derived from a SceneKit Objective-C object, like SCNNode (which inherits from NSObject), so it's pretty much impossible for me to test by removing those objects.I did try removing all overrides of Objective-C computed properties (override var ...) as suggested above, but it did not help.I also have quite a few extensions and some global utility functions, many of which extend or operate on Obj-C objects or structs. But again, removing those would totally break my app and generate a thousand errors (before Abort trap: 6 gets hit), so I can't test it.
Replies
Boosts
Views
Activity
Jun ’15
Reply to Will generics still be useful now that there are protocol extensions?
Multiple inheritance isn't supported in ObjC or Swift, but that doesn't mean it's impossible in OOP; C++ has supported multiple inheritance for a LONG time.Anyhow, you missed my point.Generics allow you to constrain to specific, homogeneous types.func foo<T>(items: [T]) { ... }Items must be an array made up of items of T.func foo(items: [T]) { ... }If T is a protocol, then items can be an array made up of anything that conforms to T. This was talked about in the talk when walking through the historical issues with OOP.Another example where the combination of protocol extensions and a generic type system really compliment one another:extension Equatable where Self : Drawable { func isEqualTo(other: Drawable) -> Bool { guard let o = other as? Self else { return false } return self == o } }That protocol extension is not possible to write without generics.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’15