Search results for

“SwiftData inheritance relationship”

4,980 results found

Post

Replies

Boosts

Views

Activity

Reply to Metal System Trace?
Thanks Kem. I was at that talk. I will give it a watch again. We were looking for a lot more, and lower level info. The time of the boxes and their relationships on the timeline is useful, but without more info about WHY some things are happening (e.g. some of the unexplained whitespace 'time') it doesn't give a lot that is actionable. But it did just help me squash some unintentional buffer reloads. 🙂Just made me realize I wish we could give encoders proper names.>>Shift+mousewheel will scroll any scrollview horizontally in OS X.Got it. Hope that gets changed. Different keys for zooming and scrolling is super awkward. Dragging time should be a drag - like pretty much any DCC application.
Aug ’15
Reply to Cant make equatable extension for PFObject
You're probably getting this error because a class which PFObject inherits from already conforms to Equatable.Since protocol conformance is inherited, you can't declare that protocol conformance again in a subclass, but you can override non-final methods required by the protocol or provide more specifically typed versions of operators.Generally, the most specific version available of overloaded functions will be used by the compiler (based on how the objects are typed in the calling code), so your implementation of == would be used for two instances typed as PFObject, rather that the parent class's version.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’15
Generating UILabel inside a UIView / Memory leak
Hi together,I have a custon view class which inherits from UIView. Inside the- (void)drawRect:(CGRect)rect {}I also generate some UILabels viaUILabel* aLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, length, height)]; [self insertSubview:aLabel atIndex:1]; [self.labelArray addObject:aLabel];I put this view into an array container to remove all labels when drawRect is called again (last line)At the beginning of my drawRect I remove all labels via for (int i = 0; i < [self.labelArray count]; i++) { [[self.labelArray objectAtIndex:i] removeFromSuperview]; }This iseems not to work because the memory usage increases during runtime.How to remove the labels without leaking memory? Is there a better way to solve this issue?
3
0
1.4k
Aug ’15
fault not getting fired on relationship end object to fetch its attribute objects.
I have an array of Location (NSManagedObject) objects called venues. each location object has a venueID attribute and a name attribute in it (as obtainted from Foursquare API).Now, I am trying to form a predicate which looks like location.venueID == <some venue id> from venueID existing in current Location object in the Venues array.the code is as follows... for (Location *venue in venues) { NSLog(@venue object %@,venue); NSPredicate *venuePredicate = [NSPredicate predicateWithFormat:@location.venueID = %@,venue.venueID]; NSLog(@venue predicate %@,venuePredicate); NSArray *sliceArray = [_fetchedResultsArray filteredArrayUsingPredicate:venuePredicate]; NSLog(@venue slice array %@,sliceArray); [slicesDictionary setValue:sliceArray forKey:venue.name]; }The predicate will be applied to a _fetchedResultsArray where the array of an entity A and Location is a relationship object. SO basically I want to filter out all A's which have location object matching the venueID provided.my problem is I checked
10
0
525
Aug ’15
sqlcipher help needed
hi all,I have inherited a legacy code which works well, but i need to implement sqlcipher into in. my app is for both android and ios, hence sqlite part is written in c++ which is also used by nadroid using JNI. hence i am unable to use ready to use library for ios and android as i use functions like sqlite3_open, sqlite3_exec. do i need to add all c++ files for sqlcipher and compile and use it ?is there a tutorial how to use it in c++ code ?regrds
0
0
263
Aug ’15
Reply to NSUserDefaults values lost on background launch
The problem here is that NSUserDefaults is ultimately backed by a file in your app’s container and your app’s container is subject to data protection. If you do nothing special then, on iOS 7 and later, your container uses NSFileProtectionCompleteUntilFirstUserAuthentication, a value that’s inherited by the NSUserDefaults backing store, and so you can’t access it prior to first unlock. IMO the best way around this is to avoid NSUserDefaults for stuff that you rely on in code paths that can execute in the background. Instead store those settings in your own preferences file, one whose data protection you can explicitly manage (in this case that means ‘set to NSFileProtectionNone’). There are two problems with NSUserDefaults in a data protection context:Its a fully abstract API: the presence and location of its backing store is not considered part of that API, so you can’t explicitly manage its data protection.Note On recent versions of OS X NSUserDefaults is managed by a daemon and folks who try to ma
Topic: Privacy & Security SubTopic: General Tags:
Aug ’15
Reply to Help making Array conform to this simple protocol
This is what I tried first:extension Array: StringInitializable where Element: StringInitializable { //error: extension of type 'Array' with constraints cannot have an inheritance clause //... }...Second try:extension Array : StringInitializable { init?(_ s : String) { let whiteSpaceRemoved = String(s.characters.filter { ! tnr.characters.contains($0) }) let bracketsRemoved = String(whiteSpaceRemoved.characters.dropFirst().dropLast()) let arrayOfStrings = bracketsRemoved.characters.split(,).map { String($0) } print(arrayOfStrings) // Prints eg [1, 2, 3] let arrayOfOptionals: [Element?] = arrayOfStrings.map { if let myElementType = Element.self as? StringInitializable.Type { return myElementType.init($0) as! Element? } else { return nil } } if arrayOfOptionals.contains({$0 == nil}) { return nil } self = arrayOfOptionals.map{$0!} } }Looks like working:let ok = [Int]([1, 2, 3]) print(ok) //->Optional([1, 2, 3]) let meh = [Int]([1, 2.0, 3]) print(meh) //->nil
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’15
Reply to The Fragile Base Class Problem
CharlesS: Am I correctly interpreting this comment to mean that Apple is planning on having non-fragile base classes by the time the ABI is stabilized?Given Swift 2's failure to require methods always reference `self` when accessing members, I'd say Good luck with that!To illustrate, consider the following example:Their library:// v 1.0 public class TheirBaseClass { public func doThis() {...} }Your program:class MyClass: TheirBaseClass { func doMyThing() { doThat() } } func doThat() {...}And this is all well and good... until they add a shiny new instance method whose name is coincidentally the same as your existing global function:// v 1.1 -- added a new method named `doThat` public class TheirBaseClass { public func doThis() {...} public func doThat() {...} }Next time you hit compile, all of a sudden your `doThat()` is being dispatched somewhere else entirely, even though your code hasn't changed at all. (Ditto for global vs inherited variables and constants too.)I can only assume someone must've m
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’15
Reply to Mutually Recursive Protocols / Compiler Crash
I asked specifically about 'coding style' because there is something about my modelling style that causes me to hit these issues _every_ time.If I don't expose `var Relationship : Set<Relationship>` and instead add methods like `addFriend`, `mapFriends`, `mapRivals`, etc (all the different facets of a Relationship - or addRelationship:as:) then the problem is avoided - Relationship becomes an implementation detail of Person. That is workable; maybe I learn something about modeling from that.Regarding the 'infinite recursion', is there not something like a `where` clause on a `typealias`?protocol Person : Hashable { var fullname : String { get set } typealias R : Relationship where R.P == Self var relationships : Set<R> { get } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’15
protocol inheritance
I have a couple of issues. The first is I want to be able to do thisprotocol A { static func someMethod() -> Self?}extension A { static func someMethod() -> Self? { ... }}protocal B: A {}extension B { static func someMethod() -> Self? { ... call protocol A's someMethod ... }}Is there a way to do this? I need to add some additional behavior to protocol B and do all of the code in protocol A's protocol extension. The best I could cope up with is have exension A have a doSomeMethod() method that does the actual work, then have both A and B call that. Is there a way to do the equivalent of super.someMethod() which doesn't work because it's not a class.
9
0
1.5k
Aug ’15
Reply to Implicit conversion loses integer precision
I would recommend that you stick to NSInteger / NSUinteger for integer values and CGFloat for floating point values (float and double). These are the default types used in the Apple libraries. They will also use the largest size (32 or 64 bit for integers) supported by the target CPU. Integer values like short, int, long, long long etc are simply defined as having a size relationship like this: short ≤ int ≤ long ≤ long long with no guarantee for the actual bit size. Type sizes can vary between compilers / OS platform. There are also a number of fixed size types (int8_t, int16_t, ... uint8_t, uint16_t, ...) if you need to ensure a specific size.
Topic: Programming Languages SubTopic: General Tags:
Aug ’15
Reply to BLE Multiple Device Communication with Time Slicing
Not exactly. You can't just set a timer and then start scanning when it expires. You need to consider that the user will press the home button or lock the phone.In those cases, your timer will stop working.What you need to do is keep scanning, and when you get the discovery callbacks, check the time to see if enough time has passed - if not, do nothing and keep checking the time. If you are actively scanning, even if your app is backgrounded, the system will activate your app when the BLE peripheral is advertising.You should also look at CoreBluetooth state preservation/restoration in case your app gets terminated by the system while in the background. More info here: https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW5I can't help you with your architecture decisions, but if it would help; another way of looking at the ce
Sep ’15
Bug: A managed object relationship that contains multiple copies of the same object.
Thanks very much for reading.Our app uses multiple NSManagedObjectContexts on multiple threads. We do the following...We want to run a background task that downloads data.We spin up a background thread.That thread creates a child context from the main one.Download some JSONUse that new data to update managed objects, creating them when necessary, object identity is tracked via a uuid string property.Save that background thread's context.Background thread goes away, taking the child context with it.On the foreground thread we are seeing a rare probably-a-timing-bug where some of our objects clone themselves in the UI. We see two copies of things in very strange ways. Different sets of objects double at different times, and they have a tendency to go away again if you wait a bit. Below is an LLDB session that demonstrates that I have an NSManagedObject that has a relationship with duplicates in it. Those duplicates have the same objectID.I've found this to be reasonably reproducible in our app by picki
7
0
768
Sep ’15
Reply to Metal System Trace?
Thanks Kem. I was at that talk. I will give it a watch again. We were looking for a lot more, and lower level info. The time of the boxes and their relationships on the timeline is useful, but without more info about WHY some things are happening (e.g. some of the unexplained whitespace 'time') it doesn't give a lot that is actionable. But it did just help me squash some unintentional buffer reloads. 🙂Just made me realize I wish we could give encoders proper names.>>Shift+mousewheel will scroll any scrollview horizontally in OS X.Got it. Hope that gets changed. Different keys for zooming and scrolling is super awkward. Dragging time should be a drag - like pretty much any DCC application.
Replies
Boosts
Views
Activity
Aug ’15
Reply to Cant make equatable extension for PFObject
You're probably getting this error because a class which PFObject inherits from already conforms to Equatable.Since protocol conformance is inherited, you can't declare that protocol conformance again in a subclass, but you can override non-final methods required by the protocol or provide more specifically typed versions of operators.Generally, the most specific version available of overloaded functions will be used by the compiler (based on how the objects are typed in the calling code), so your implementation of == would be used for two instances typed as PFObject, rather that the parent class's version.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’15
Generating UILabel inside a UIView / Memory leak
Hi together,I have a custon view class which inherits from UIView. Inside the- (void)drawRect:(CGRect)rect {}I also generate some UILabels viaUILabel* aLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, length, height)]; [self insertSubview:aLabel atIndex:1]; [self.labelArray addObject:aLabel];I put this view into an array container to remove all labels when drawRect is called again (last line)At the beginning of my drawRect I remove all labels via for (int i = 0; i < [self.labelArray count]; i++) { [[self.labelArray objectAtIndex:i] removeFromSuperview]; }This iseems not to work because the memory usage increases during runtime.How to remove the labels without leaking memory? Is there a better way to solve this issue?
Replies
3
Boosts
0
Views
1.4k
Activity
Aug ’15
fault not getting fired on relationship end object to fetch its attribute objects.
I have an array of Location (NSManagedObject) objects called venues. each location object has a venueID attribute and a name attribute in it (as obtainted from Foursquare API).Now, I am trying to form a predicate which looks like location.venueID == <some venue id> from venueID existing in current Location object in the Venues array.the code is as follows... for (Location *venue in venues) { NSLog(@venue object %@,venue); NSPredicate *venuePredicate = [NSPredicate predicateWithFormat:@location.venueID = %@,venue.venueID]; NSLog(@venue predicate %@,venuePredicate); NSArray *sliceArray = [_fetchedResultsArray filteredArrayUsingPredicate:venuePredicate]; NSLog(@venue slice array %@,sliceArray); [slicesDictionary setValue:sliceArray forKey:venue.name]; }The predicate will be applied to a _fetchedResultsArray where the array of an entity A and Location is a relationship object. SO basically I want to filter out all A's which have location object matching the venueID provided.my problem is I checked
Replies
10
Boosts
0
Views
525
Activity
Aug ’15
sqlcipher help needed
hi all,I have inherited a legacy code which works well, but i need to implement sqlcipher into in. my app is for both android and ios, hence sqlite part is written in c++ which is also used by nadroid using JNI. hence i am unable to use ready to use library for ios and android as i use functions like sqlite3_open, sqlite3_exec. do i need to add all c++ files for sqlcipher and compile and use it ?is there a tutorial how to use it in c++ code ?regrds
Replies
0
Boosts
0
Views
263
Activity
Aug ’15
Reply to NSUserDefaults values lost on background launch
The problem here is that NSUserDefaults is ultimately backed by a file in your app’s container and your app’s container is subject to data protection. If you do nothing special then, on iOS 7 and later, your container uses NSFileProtectionCompleteUntilFirstUserAuthentication, a value that’s inherited by the NSUserDefaults backing store, and so you can’t access it prior to first unlock. IMO the best way around this is to avoid NSUserDefaults for stuff that you rely on in code paths that can execute in the background. Instead store those settings in your own preferences file, one whose data protection you can explicitly manage (in this case that means ‘set to NSFileProtectionNone’). There are two problems with NSUserDefaults in a data protection context:Its a fully abstract API: the presence and location of its backing store is not considered part of that API, so you can’t explicitly manage its data protection.Note On recent versions of OS X NSUserDefaults is managed by a daemon and folks who try to ma
Topic: Privacy & Security SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’15
Reply to Help making Array conform to this simple protocol
This is what I tried first:extension Array: StringInitializable where Element: StringInitializable { //error: extension of type 'Array' with constraints cannot have an inheritance clause //... }...Second try:extension Array : StringInitializable { init?(_ s : String) { let whiteSpaceRemoved = String(s.characters.filter { ! tnr.characters.contains($0) }) let bracketsRemoved = String(whiteSpaceRemoved.characters.dropFirst().dropLast()) let arrayOfStrings = bracketsRemoved.characters.split(,).map { String($0) } print(arrayOfStrings) // Prints eg [1, 2, 3] let arrayOfOptionals: [Element?] = arrayOfStrings.map { if let myElementType = Element.self as? StringInitializable.Type { return myElementType.init($0) as! Element? } else { return nil } } if arrayOfOptionals.contains({$0 == nil}) { return nil } self = arrayOfOptionals.map{$0!} } }Looks like working:let ok = [Int]([1, 2, 3]) print(ok) //->Optional([1, 2, 3]) let meh = [Int]([1, 2.0, 3]) print(meh) //->nil
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’15
Reply to The Fragile Base Class Problem
CharlesS: Am I correctly interpreting this comment to mean that Apple is planning on having non-fragile base classes by the time the ABI is stabilized?Given Swift 2's failure to require methods always reference `self` when accessing members, I'd say Good luck with that!To illustrate, consider the following example:Their library:// v 1.0 public class TheirBaseClass { public func doThis() {...} }Your program:class MyClass: TheirBaseClass { func doMyThing() { doThat() } } func doThat() {...}And this is all well and good... until they add a shiny new instance method whose name is coincidentally the same as your existing global function:// v 1.1 -- added a new method named `doThat` public class TheirBaseClass { public func doThis() {...} public func doThat() {...} }Next time you hit compile, all of a sudden your `doThat()` is being dispatched somewhere else entirely, even though your code hasn't changed at all. (Ditto for global vs inherited variables and constants too.)I can only assume someone must've m
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’15
Reply to Why can't Protocols be nested in other Types?
What I fail to understand is why you want to abstract it out of the class the first place. It's just a single method.And as a second point: protocols are intended, as in Obj-C, to define behaviour like compareable. It is not a poor mans multiple inheritance as interfaces in java or c++.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’15
Reply to Mutually Recursive Protocols / Compiler Crash
I asked specifically about 'coding style' because there is something about my modelling style that causes me to hit these issues _every_ time.If I don't expose `var Relationship : Set<Relationship>` and instead add methods like `addFriend`, `mapFriends`, `mapRivals`, etc (all the different facets of a Relationship - or addRelationship:as:) then the problem is avoided - Relationship becomes an implementation detail of Person. That is workable; maybe I learn something about modeling from that.Regarding the 'infinite recursion', is there not something like a `where` clause on a `typealias`?protocol Person : Hashable { var fullname : String { get set } typealias R : Relationship where R.P == Self var relationships : Set<R> { get } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’15
protocol inheritance
I have a couple of issues. The first is I want to be able to do thisprotocol A { static func someMethod() -> Self?}extension A { static func someMethod() -> Self? { ... }}protocal B: A {}extension B { static func someMethod() -> Self? { ... call protocol A's someMethod ... }}Is there a way to do this? I need to add some additional behavior to protocol B and do all of the code in protocol A's protocol extension. The best I could cope up with is have exension A have a doSomeMethod() method that does the actual work, then have both A and B call that. Is there a way to do the equivalent of super.someMethod() which doesn't work because it's not a class.
Replies
9
Boosts
0
Views
1.5k
Activity
Aug ’15
Reply to Implicit conversion loses integer precision
I would recommend that you stick to NSInteger / NSUinteger for integer values and CGFloat for floating point values (float and double). These are the default types used in the Apple libraries. They will also use the largest size (32 or 64 bit for integers) supported by the target CPU. Integer values like short, int, long, long long etc are simply defined as having a size relationship like this: short ≤ int ≤ long ≤ long long with no guarantee for the actual bit size. Type sizes can vary between compilers / OS platform. There are also a number of fixed size types (int8_t, int16_t, ... uint8_t, uint16_t, ...) if you need to ensure a specific size.
Topic: Programming Languages SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’15
Reply to Mixing ObjC and Swift: can't override NSUnavailable in a subclass
It's a bug. Your subclass initializer wouldn't really be an override of the parent initializer; they just happen to have the same name. Since initializers aren't automatically inherited in Swift, this would be perfectly safe. Please file a bug report!
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’15
Reply to BLE Multiple Device Communication with Time Slicing
Not exactly. You can't just set a timer and then start scanning when it expires. You need to consider that the user will press the home button or lock the phone.In those cases, your timer will stop working.What you need to do is keep scanning, and when you get the discovery callbacks, check the time to see if enough time has passed - if not, do nothing and keep checking the time. If you are actively scanning, even if your app is backgrounded, the system will activate your app when the BLE peripheral is advertising.You should also look at CoreBluetooth state preservation/restoration in case your app gets terminated by the system while in the background. More info here: https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW5I can't help you with your architecture decisions, but if it would help; another way of looking at the ce
Replies
Boosts
Views
Activity
Sep ’15
Bug: A managed object relationship that contains multiple copies of the same object.
Thanks very much for reading.Our app uses multiple NSManagedObjectContexts on multiple threads. We do the following...We want to run a background task that downloads data.We spin up a background thread.That thread creates a child context from the main one.Download some JSONUse that new data to update managed objects, creating them when necessary, object identity is tracked via a uuid string property.Save that background thread's context.Background thread goes away, taking the child context with it.On the foreground thread we are seeing a rare probably-a-timing-bug where some of our objects clone themselves in the UI. We see two copies of things in very strange ways. Different sets of objects double at different times, and they have a tendency to go away again if you wait a bit. Below is an LLDB session that demonstrates that I have an NSManagedObject that has a relationship with duplicates in it. Those duplicates have the same objectID.I've found this to be reasonably reproducible in our app by picki
Replies
7
Boosts
0
Views
768
Activity
Sep ’15