Search results for

“SwiftData inheritance relationship”

4,980 results found

Post

Replies

Boosts

Views

Activity

Reply to Design decisions / goals / philosophy of Swift
Am I correct in thinking that your complaint is essentially that flatMap() is not equivalent to map() followed by flatten()?Sometimes it's described that way (by other comments in the stdlib), but in the case where the supplied transform produces an Optional, the flatten() seems to be replaced by a non-nil filter and unwrapping. flatten() does not seem to be defined on Optionals, nor on sequences of Optionals, so the follow-up operation performed by flatMap() in the case of optional-producing transforms has no apparent relationship to flattening.If that's the crux of your argument, I agree; the current definitions seem inconsistent and kind of random to me. But I don't have much background in FP. You mention that Swift's flatMap() seems similar to that of Scala. So what's Scala's excuse?
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to Design decisions / goals / philosophy of Swift
Because mathematics in huge parts just plainly fails in describing reality.I'm sure Sir Isacc Newton would be very surprised to hear this.Actually, what mathematics is extremely good at is describing the relationships between things. Which is what declarative, e.g. functional, programming languages also do - allowing you to describe the relationships between your inputs and outputs, while leaving it up to the machine to figure out how/when/if/where to perform the actual calculations. What math is not so good at is describing relationships between state and time. Mind you, neither are your imperative programming languages - the fact that they can do it at all doesn't mean they actually do it well. Especially when non-determinism gets involved - i.e. anything other than a single-threaded single process that never interacts with shared resources - a naive conceit that is comically unrealistic in this modern ubiquitously networked world, but which a great many programmers seem to cling
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to Design decisions / goals / philosophy of Swift
I think it's important to be clear here: contrary to any popular programmer memes currently in circulation (cough), Swift is not in any way functional and cannot do functional programming, period. Swift is an imperative language, and imperative means the user has to state every single computation in the exact order it's to be performed, and the machine has to follow those instructions to the letter because it simply doesn't have the insight or guarantees necessary to make intelligent decisions about what needs to be done and when for itself.Declarative programming is higher level programming, where you state what you want - e.g. as a set of logic rules, or pipeline transformations, or input-output relationships - and it's left to the machine to figure out exactly when, where, and what calculations it needs to perform in order to produce the requested result. Thus what distinguishes a language like Haskell from Swift or C is not all the things it can do but the things it cannot, because it is those re
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to Bug: A managed object relationship that contains multiple copies of the same object.
A little more info.It is not necessary for the copies of the object to disagree on their temporaryness for this bug to show up. I saw it happen with both objects being non-temporary.Manually looping over the collections and removing duplicates any time this particular background thread changes any relationship seems to have done the trick. Yuck.
Sep ’15
Reply to Add UILayoutGuide in Interface Builder?
I don't think it is available in IB yet. In video 219 Mysteries of Autolayout part 2, there is extensive use of UILayoutGuide in the AstroLayout sample code. I have downlaoded the code. But it is all done in the code, not in IB.UILayoutGuide inherits directly from NSObject, not from UIView, which could make it harder to add conveniently to Xcode.
Sep ’15
Reply to Why is -> in Swift?
The colon represents a type declaration for a property, variable, constant, etc., or type inheritance/conformance (which is also a kind of type declaration) for a class, struct or protocol. To me, the arrow represents a mapping which I think is really appropriate and natural for functions (or more generally closures) just as it is used in Swift.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to Universal Links in Web Markup
Applinks and twitter cards' markup are their own thing and I haven't seen either comment on changes for iOS 9. I would wait until they say something before you change it. The custom URL schemes you setup for your app could still be used by JavaScript to check availability since to my knowledge js will have no way to know if a link is a universal linkAs far as native apps knowing your app is installed the options are now pretty limited unless there is a predefined relationship you setup in your plist because canOpenURL now returns NO for anything not found under the new LSApplicationQueriesSchemes key.
Topic: App & System Services SubTopic: General Tags:
Sep ’15
Reply to `protocol Drawable {}` vs `protocol Drawable : Equatable {}`
> Given that it is a bit difficult to forecast how a protocol will be subsequently usedThat's what I thought at first, too. After some hours of discussion I realized that that seems to be my (and maybe your's and others') misconception about protocols:In reality you know excactly how a protocol will be used because you design it for a special usecase ie. the protocol defines the usecase.I will try to discuss this in the following:In the case of Equatable the usecase is compare two entities of the same typeHashable builds ontop of this usecase. get a hashvalue for an entity which is comparable with entites of it's own typeThe Dictionary struct - by relying on the Hashable protocol - explicitly defines it's usecase as Mapping homogenous keys to (heterogenous) valuesIn the same way the Set struct explicitly states to only containing homogenous data - by relying on the Hashable protocol, transitively relying on the Equatable protocol.The usecase for Equatable is not compare suff but compare homogenous stuff. T
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to How do I interrogate UIUserNotificationType returned from UIApplication.sharedApplication().currentUserNotificationSettings().types
Where did .allZeros come from? I had been using .None which had been seeming to work! The allZeros property is defined in BitwiseOperationsType which is inherited by RawOptionSetType. In all (as far as I know) RawOptionSetTypes, .None is exactly the same as BitwiseOperationsType.allZeros, so you can use any of them as you prefer. I tend to use allZeros where bitwise operations included.
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to unimplemented initializer error makes no sense
Maybe because I'm building for iOS 8 and running 8.4 iPad? Did you test on 9.0?That's it. I could reproduce your issue with iOS 8.4 sim. Sorry for having missed such basic settings.Another work around is to make your init(thing:) a convenience initializer. (You need to make `thing` as Thing! in this case as well.)class MyViewController: UITableViewController { var thing: Thing! convenience init(thing: Thing) { self.init(style: .Grouped) self.thing = thing } //No designated init cannot appear... }While adding only convenience initializers, your class can inherit all designated initializers including init(nibName:bundle:) .
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to inter-module optimization?
Swift's standard library has: 94 structs, 74 protocols and 5 classes.(And I can only see one case of inheritance (the ManagedBuffer class inherits from the ManagedProtoBuffer class).)So if OOP is about objects with identity (ie instances of classes in Swift) that interact with one another, then at least Swift's standard library is not OOP.Swift's standard library is designed in a way that is totally different from a typical Objective-C or let's say Java framework where practically everything is about objects with identity (classes that inherits from NSObject or Object).And, as can be seen in the 2015 WWDC talk linked to by Wallacy: Dave Abrahams (technical lead for the Swift standard Library) says Swift is the first protocol-oriented programming language.Wikipedia describes Swift as multi paradigm and Objective-C as object oriented.But when people say OOP, they don't always mean something along the lines of Smalltalk/Alan Kay. So I think using fuzzy labels like OOP, FP and multi par
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Protocol Oriented Programming and the Delegate Pattern
A WWDC 2015 session video describes the idea of Protocol-Oriented Programming, and I want to adopt this technique in my future apps. I've been playing around with Swift 2.0 for the last couple of days in order to understand this new approach, and am stuck at trying to make it work with the Delegate Pattern.I have two protocols that define the basic structure of the interesting part of my project (the example code is nonsense but describes the problem):1) A delegation protocol that makes accessible some information, similar to UITableViewController's dataSource protocol:protocol ValueProvider { var value: Int { get } }2) An interface protocol of the entity that does something with the information from above (here's where the idea of a Protocol-First approach comes into play):protocol DataProcessor { var provider: ValueProvider { get } func process() -> Int }Regarding the actual implementation of the data processor, I can now choose between enums, structs, and classes. There are several different abstraction
8
0
3.0k
Sep ’15
Status bar stays black even when set to light
Hi,first pardon me if I made a post on the wrong forum part, this is my first post on this forum so I am still trying to figure my way around.Now, here is a problem I am experiencing:I have app compatible with iPad and iPhone in Swift, supporting iOS 7 and 8, using XCode 6.4. Now I made app structured as master-detail control and set in split controller status bar to be light (white). In Storyboard, all controllers display white status bar (master, detail, naigation controllers...) but nor in simulator nor in iPhone / iPad is white but black!I tried in each controller and its naviagator controller to set light status bar. Tried in Master view controller to set it. Tried to add in plist option that allows me setting up per view controller (note that I do not want to control status bar color per controller but to set global for the app). Also tried to set override function for status bar style and even reload function in viewDidLoad func. And nothing worked. 😟I am really stuck here; I thought just set in split
3
0
26k
Sep ’15
Reply to Design decisions / goals / philosophy of Swift
Am I correct in thinking that your complaint is essentially that flatMap() is not equivalent to map() followed by flatten()?Sometimes it's described that way (by other comments in the stdlib), but in the case where the supplied transform produces an Optional, the flatten() seems to be replaced by a non-nil filter and unwrapping. flatten() does not seem to be defined on Optionals, nor on sequences of Optionals, so the follow-up operation performed by flatMap() in the case of optional-producing transforms has no apparent relationship to flattening.If that's the crux of your argument, I agree; the current definitions seem inconsistent and kind of random to me. But I don't have much background in FP. You mention that Swift's flatMap() seems similar to that of Scala. So what's Scala's excuse?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to Design decisions / goals / philosophy of Swift
Because mathematics in huge parts just plainly fails in describing reality.I'm sure Sir Isacc Newton would be very surprised to hear this.Actually, what mathematics is extremely good at is describing the relationships between things. Which is what declarative, e.g. functional, programming languages also do - allowing you to describe the relationships between your inputs and outputs, while leaving it up to the machine to figure out how/when/if/where to perform the actual calculations. What math is not so good at is describing relationships between state and time. Mind you, neither are your imperative programming languages - the fact that they can do it at all doesn't mean they actually do it well. Especially when non-determinism gets involved - i.e. anything other than a single-threaded single process that never interacts with shared resources - a naive conceit that is comically unrealistic in this modern ubiquitously networked world, but which a great many programmers seem to cling
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to Design decisions / goals / philosophy of Swift
I think it's important to be clear here: contrary to any popular programmer memes currently in circulation (cough), Swift is not in any way functional and cannot do functional programming, period. Swift is an imperative language, and imperative means the user has to state every single computation in the exact order it's to be performed, and the machine has to follow those instructions to the letter because it simply doesn't have the insight or guarantees necessary to make intelligent decisions about what needs to be done and when for itself.Declarative programming is higher level programming, where you state what you want - e.g. as a set of logic rules, or pipeline transformations, or input-output relationships - and it's left to the machine to figure out exactly when, where, and what calculations it needs to perform in order to produce the requested result. Thus what distinguishes a language like Haskell from Swift or C is not all the things it can do but the things it cannot, because it is those re
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to Bug: A managed object relationship that contains multiple copies of the same object.
A little more info.It is not necessary for the copies of the object to disagree on their temporaryness for this bug to show up. I saw it happen with both objects being non-temporary.Manually looping over the collections and removing duplicates any time this particular background thread changes any relationship seems to have done the trick. Yuck.
Replies
Boosts
Views
Activity
Sep ’15
Reply to Add UILayoutGuide in Interface Builder?
I don't think it is available in IB yet. In video 219 Mysteries of Autolayout part 2, there is extensive use of UILayoutGuide in the AstroLayout sample code. I have downlaoded the code. But it is all done in the code, not in IB.UILayoutGuide inherits directly from NSObject, not from UIView, which could make it harder to add conveniently to Xcode.
Replies
Boosts
Views
Activity
Sep ’15
Reply to Why is -> in Swift?
The colon represents a type declaration for a property, variable, constant, etc., or type inheritance/conformance (which is also a kind of type declaration) for a class, struct or protocol. To me, the arrow represents a mapping which I think is really appropriate and natural for functions (or more generally closures) just as it is used in Swift.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to Universal Links in Web Markup
Applinks and twitter cards' markup are their own thing and I haven't seen either comment on changes for iOS 9. I would wait until they say something before you change it. The custom URL schemes you setup for your app could still be used by JavaScript to check availability since to my knowledge js will have no way to know if a link is a universal linkAs far as native apps knowing your app is installed the options are now pretty limited unless there is a predefined relationship you setup in your plist because canOpenURL now returns NO for anything not found under the new LSApplicationQueriesSchemes key.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to `protocol Drawable {}` vs `protocol Drawable : Equatable {}`
> Given that it is a bit difficult to forecast how a protocol will be subsequently usedThat's what I thought at first, too. After some hours of discussion I realized that that seems to be my (and maybe your's and others') misconception about protocols:In reality you know excactly how a protocol will be used because you design it for a special usecase ie. the protocol defines the usecase.I will try to discuss this in the following:In the case of Equatable the usecase is compare two entities of the same typeHashable builds ontop of this usecase. get a hashvalue for an entity which is comparable with entites of it's own typeThe Dictionary struct - by relying on the Hashable protocol - explicitly defines it's usecase as Mapping homogenous keys to (heterogenous) valuesIn the same way the Set struct explicitly states to only containing homogenous data - by relying on the Hashable protocol, transitively relying on the Equatable protocol.The usecase for Equatable is not compare suff but compare homogenous stuff. T
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to Why can't Protocols be nested in other Types?
Well Swift protocols aren't designed to provide abstraction and namespacing. Of course they will have problem if you try to use them in this manner.The namespacing mechanism in Swift are modules and for abstraction generic classes with inheritance.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to How do I interrogate UIUserNotificationType returned from UIApplication.sharedApplication().currentUserNotificationSettings().types
Where did .allZeros come from? I had been using .None which had been seeming to work! The allZeros property is defined in BitwiseOperationsType which is inherited by RawOptionSetType. In all (as far as I know) RawOptionSetTypes, .None is exactly the same as BitwiseOperationsType.allZeros, so you can use any of them as you prefer. I tend to use allZeros where bitwise operations included.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to unimplemented initializer error makes no sense
Maybe because I'm building for iOS 8 and running 8.4 iPad? Did you test on 9.0?That's it. I could reproduce your issue with iOS 8.4 sim. Sorry for having missed such basic settings.Another work around is to make your init(thing:) a convenience initializer. (You need to make `thing` as Thing! in this case as well.)class MyViewController: UITableViewController { var thing: Thing! convenience init(thing: Thing) { self.init(style: .Grouped) self.thing = thing } //No designated init cannot appear... }While adding only convenience initializers, your class can inherit all designated initializers including init(nibName:bundle:) .
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Reply to inter-module optimization?
Swift's standard library has: 94 structs, 74 protocols and 5 classes.(And I can only see one case of inheritance (the ManagedBuffer class inherits from the ManagedProtoBuffer class).)So if OOP is about objects with identity (ie instances of classes in Swift) that interact with one another, then at least Swift's standard library is not OOP.Swift's standard library is designed in a way that is totally different from a typical Objective-C or let's say Java framework where practically everything is about objects with identity (classes that inherits from NSObject or Object).And, as can be seen in the 2015 WWDC talk linked to by Wallacy: Dave Abrahams (technical lead for the Swift standard Library) says Swift is the first protocol-oriented programming language.Wikipedia describes Swift as multi paradigm and Objective-C as object oriented.But when people say OOP, they don't always mean something along the lines of Smalltalk/Alan Kay. So I think using fuzzy labels like OOP, FP and multi par
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Sep ’15
Protocol Oriented Programming and the Delegate Pattern
A WWDC 2015 session video describes the idea of Protocol-Oriented Programming, and I want to adopt this technique in my future apps. I've been playing around with Swift 2.0 for the last couple of days in order to understand this new approach, and am stuck at trying to make it work with the Delegate Pattern.I have two protocols that define the basic structure of the interesting part of my project (the example code is nonsense but describes the problem):1) A delegation protocol that makes accessible some information, similar to UITableViewController's dataSource protocol:protocol ValueProvider { var value: Int { get } }2) An interface protocol of the entity that does something with the information from above (here's where the idea of a Protocol-First approach comes into play):protocol DataProcessor { var provider: ValueProvider { get } func process() -> Int }Regarding the actual implementation of the data processor, I can now choose between enums, structs, and classes. There are several different abstraction
Replies
8
Boosts
0
Views
3.0k
Activity
Sep ’15
Status bar stays black even when set to light
Hi,first pardon me if I made a post on the wrong forum part, this is my first post on this forum so I am still trying to figure my way around.Now, here is a problem I am experiencing:I have app compatible with iPad and iPhone in Swift, supporting iOS 7 and 8, using XCode 6.4. Now I made app structured as master-detail control and set in split controller status bar to be light (white). In Storyboard, all controllers display white status bar (master, detail, naigation controllers...) but nor in simulator nor in iPhone / iPad is white but black!I tried in each controller and its naviagator controller to set light status bar. Tried in Master view controller to set it. Tried to add in plist option that allows me setting up per view controller (note that I do not want to control status bar color per controller but to set global for the app). Also tried to set override function for status bar style and even reload function in viewDidLoad func. And nothing worked. 😟I am really stuck here; I thought just set in split
Replies
3
Boosts
0
Views
26k
Activity
Sep ’15
Reply to fault not getting fired on relationship end object to fetch its attribute objects.
I think I have identified the problem. fault is not being fired on the relationship object to fetch its attributes.any help?
Replies
Boosts
Views
Activity
Sep ’15