Search results for

“SwiftData inheritance relationship”

4,981 results found

Post

Replies

Boosts

Views

Activity

Reply to For-in-loop on custom types for which SequenceType doesn't make sense.
Another way to explain why I'd like to be able to use my type(s) with for-in without getting all stuff from SequenceType et al might be by this example:TL;DR:My StaticArrayType(s) has type-level Count, thus SequenceType == bad fit, OK, fine, makes sense. But I'd still like to:for e in myStaticArray { … }I could have, if only the stdlib had a simpler protocol whose only requirement was that conforming types had a generate() method.I have a protocol called StaticArrayType which describes a set of common requirements for concrete (value) types that have/are a statically allocated fixed number of elements (of type Element). So the memory layout of any static array type is fixed and both its element type and its count are encoded at the type level by associated types Element: DefaultInitializable andCount: CountType.The Count type can be used to type check the number of elements and the Element type can be used to type check the element type.(The memory layout of any static array type is fixed and known since eg a
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’15
Reply to Swift and InterfaceBuilder Question... can't get IB to find Swift Classes.
I ran into the same problem, with the same solution, in using an NSObject derived class and binding an Array Controller to a Table View.So question, when do we need to add @objc(ClassName) for an NSObject derived class ?I read in « Using Swift with Cocoa and Objective-C. » that« When you define a Swift class that inherits from NSObject or any other Objective-C class, the class is automatically compatible with Objective-C. All of the steps in this section have already been done for you by the Swift compiler. »It also says:« The @objc attribute makes your Swift API available in Objective-C and the Objective-C runtime. »Is binding calling Objective C runtime in the background (My code is pure Swift) ?
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’15
Reply to Implicit / transitive protocol conformance for conforming properties?
It is type save to return a derrived type, co-varient return tpe overloads are common in many type-safe languages. In this case all BarModels are BarViewModels, therefore you can always (1) put a BarModel where a BarViewModel is expected. You can see this in the class version that allows, and works as expected, getBar() -> BarModel to override getBar() -> BarViewModel.However even though it is type safe to have co-varient return types the language could just simply ban this, early versions of Java did for example. Therefore the reason I think it is a bug is because co-varient return types are allowed in classes and you should be able to change a class into a protocol (provided that there is no functionality used in the class that cannot be expressed as a protocol). In this specific case you can declare a method in both a class and a protocol and therefore I would expect the same declarion in a different context, class or protocol, to have the same meaning.(1) The statement you can always put a BarModel
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’15
Possible to sort iCloud query results on field of referenced record?
Say I have the following:Record1title1 : String()record2 : Reference()- This is a reference to Record 2record3 : Reference()- This is a reference to Record 3Record2:title2 : String()If I'm doing a search through Record 1 for references to a particular Record 2 (the relationship between the two records is many-to-many) is it possible to sort my results of the query by title2?I have the following code:let predicate = NSPredicate(format: record2 = %@, recordTwo.recordID)let sort = NSSortDescriptor(key: ***record2.title2***, ascending: true) //Not sure what I put in between the here. Please help.let query = CKQuery(recordType: Record1, predicate: predicate)query.sortDescriptors = [sort]
0
0
181
Nov ’15
Possible to sort iCloud query results on field of referenced record?
Say I have the following:Record1title1 : String()record2 : Reference()- This is a reference to Record 2record3 : Reference()- This is a reference to Record 3Record2:title2 : String()If I'm doing a search through Record 1 for references to a particular Record 2 (the relationship between the two records is many-to-many) is it possible to sort my results of the query by title2?I have the following code:let predicate = NSPredicate(format: record2 = %@, recordTwo.recordID)let sort = NSSortDescriptor(key: ***record2.title2***, ascending: true) //Not sure what I put in between the here. Please help.let query = CKQuery(recordType: Record1, predicate: predicate)query.sortDescriptors = [sort]
0
0
224
Nov ’15
Core Data Objective C
Hello everyone, I have an issue that I cannot figure out, been at it for quite some time now.My goal is to populate a NSMutableArray and save it to core data and retrieve it. My tableview is being populated correctly , i.e. I am using Group and populating the titleForHeaderInSection. But when I terminate the app and try to do a Fetch and cast to an NSMutableArray the data is unreadable and my app is crashing.This is my NSMutableArray *sectionNames , what it looks like after being populated. The NewObject has this in it <Car_Doc_Safe_Plus.CarName: 0x7fc2226cf080> (entity: CarName; id: 0xd000000000080000 <x-coredata:/ carsname = (n Ram,n Jeepn); relationship = nil;This is my Termination when I try to Fetch. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Car_Doc_Safe_Plus.CarName length]: unrecognized selector sent to instance 0x7fd783ce3130'This is my save to Core Data; My entity is set up to receive NSString , I also tried - transformable - with no luck
2
0
1.5k
Nov ’15
Disabling Scrolling then Setting ContentOffset in UITextView only makes the text in the top content of TextView visible, how do we make the text in that range visible?
I made a full view DrawBoard class which is inherited from a UITextView class.When the switch on the view controller is on the user can type and scroll, when it is off the user can draw on the Drawboard.@IBAction func changeSwitch(sender: UISwitch) { if sender.on{ drawBoard.setNeedsDisplay() drawBoard.scrollEnabled = true drawBoard.editable = true drawBoard.selectable = true drawBoard.switchBool = false }else if !sender.on { drawBoard.switchBool=true let a:CGPoint = drawBoard.contentOffset drawBoard.scrollEnabled = false drawBoard.setContentOffset(a, animated: false) drawBoard.editable = false drawBoard.selectable=false } }It updates the scrolling but scrollEnabled= false just saves the text that is in the first page range of the textview so that it scrolls to the top automatically and disable the scrolling there.Then when I do the setContentOffset the drawable view of the background is visible and it draws on the right place of the textview. However the text that should be on top of it is not visibl
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
2.2k
Nov ’15
Reply to Why no Self within structs?
This doesn't compile:class C { var someProperty: Self {return self} }and it's pointless for either to compile:protocol CType {} extension CType { func someMethod() -> Self {return self} var someProperty: Self {return self} }Reference types being tied in with inheritance is a weird overload.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’15
Reply to Why no Self within structs?
Inheritance is ridiculous and I expect that it will be deprecated in Swift for non-objc types.protocol ThingType {} extension ThingType { static var name: String {return ThingType} } class Thing: ThingType { static var defaultName: String {return (Thing.self as ThingType.Type).name} static var name = Thing }
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’15
Reply to Why no Self within structs?
As the title says: structs (not classes) ... so I repeat:This is (at least the beginning of) a great example of why I'm staying away from classes, not to mention inheritance, as much as I possibly can in my code, and in (the topic of) this thread. : )
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’15
Reply to Why no Self within structs?
I think bob133 gave you the correct answer accidentally. 'Self' as the return type in a class is exactly what 'instancetype' is in Obj-C. It means a class determined by the call site, which may be a subclass of the class of the declaration site of the method. In fact, using the class name instead is semantically different from Self.In structs, without any inheritance, the only possibility is the struct containing the declaration, so you can use the literal name of the type. OTOH, allowing 'Self' would seem to be harmless.As far as protocols are concerned (and classes using Self conforming to protocols using Self), I was not able to find documentation on what it means, the last time I looked.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’15
Xcode unable to compile xcdatamodeld
Hello,Xcode stalls on compiling the xcdatamodeld Core Data file when attempting to build my project.This is only happening (to my knowledge) for this project in particular.The following is shown in the Report Navigator in Xcode, under the target for the App. This is what the compiler endlessly tries to compile.DataModelCompile DerivedData/Unitu/Build/Intermediates/ArchiveIntermediates/Unitu/InstallationBuildProductsLocation/Applications/Unitu.app/ Unitu/UnituAPIDataModel.xcdatamodeld cd /Users/jamesbellamy/Desktop/unitu export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin /Applications/Xcode.app/Contents/Developer/usr/bin/momc --sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk --iphoneos-deployment-target 8.0 --module Unitu /Users/jamesbellamy/Desktop/unitu/Unitu/UnituAPIDataModel.xcdatamodeld /Users/jamesbe
1
0
865
Dec ’15
Including code and storage
One problem I have always had with Objective C. and now Swift, is the lack of multiple inheritance. I have certain functionality I would like to add to a number os disparate classes without having to replicate the code. Catagories (and Swift extensions) don't allow storage, and are specific to a particular class. In Objective C, I had considered the use of a simple include file, but I'm not sure it that works in Swift, and am not sure of the implications in debugging. Many classes, eg, views and view controllers, already inherit from other classes, so a common base class is out of the question. Is there any good way to do this?
8
0
406
Dec ’15
Reply to Including code and storage
I believe that means the (stored) properties have to be defined in the class that adopted the protocol. I have to say that I am confused by protocol extensions. The extension is to the protocol. Is that effectively the same as the class having that extension, and that the etension methods can be called from an object of that class? Then the protocol itself says what must be defined in the class for calls from the extension methods. Do I have that right?One issue is that if i had multiple inheritance, I could define methods which need to be overriden in the new class. But that is not possible with protocols and extensions.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’15
Reply to For-in-loop on custom types for which SequenceType doesn't make sense.
Another way to explain why I'd like to be able to use my type(s) with for-in without getting all stuff from SequenceType et al might be by this example:TL;DR:My StaticArrayType(s) has type-level Count, thus SequenceType == bad fit, OK, fine, makes sense. But I'd still like to:for e in myStaticArray { … }I could have, if only the stdlib had a simpler protocol whose only requirement was that conforming types had a generate() method.I have a protocol called StaticArrayType which describes a set of common requirements for concrete (value) types that have/are a statically allocated fixed number of elements (of type Element). So the memory layout of any static array type is fixed and both its element type and its count are encoded at the type level by associated types Element: DefaultInitializable andCount: CountType.The Count type can be used to type check the number of elements and the Element type can be used to type check the element type.(The memory layout of any static array type is fixed and known since eg a
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’15
Reply to Swift and InterfaceBuilder Question... can't get IB to find Swift Classes.
I ran into the same problem, with the same solution, in using an NSObject derived class and binding an Array Controller to a Table View.So question, when do we need to add @objc(ClassName) for an NSObject derived class ?I read in « Using Swift with Cocoa and Objective-C. » that« When you define a Swift class that inherits from NSObject or any other Objective-C class, the class is automatically compatible with Objective-C. All of the steps in this section have already been done for you by the Swift compiler. »It also says:« The @objc attribute makes your Swift API available in Objective-C and the Objective-C runtime. »Is binding calling Objective C runtime in the background (My code is pure Swift) ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’15
Reply to Implicit / transitive protocol conformance for conforming properties?
It is type save to return a derrived type, co-varient return tpe overloads are common in many type-safe languages. In this case all BarModels are BarViewModels, therefore you can always (1) put a BarModel where a BarViewModel is expected. You can see this in the class version that allows, and works as expected, getBar() -> BarModel to override getBar() -> BarViewModel.However even though it is type safe to have co-varient return types the language could just simply ban this, early versions of Java did for example. Therefore the reason I think it is a bug is because co-varient return types are allowed in classes and you should be able to change a class into a protocol (provided that there is no functionality used in the class that cannot be expressed as a protocol). In this specific case you can declare a method in both a class and a protocol and therefore I would expect the same declarion in a different context, class or protocol, to have the same meaning.(1) The statement you can always put a BarModel
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’15
Possible to sort iCloud query results on field of referenced record?
Say I have the following:Record1title1 : String()record2 : Reference()- This is a reference to Record 2record3 : Reference()- This is a reference to Record 3Record2:title2 : String()If I'm doing a search through Record 1 for references to a particular Record 2 (the relationship between the two records is many-to-many) is it possible to sort my results of the query by title2?I have the following code:let predicate = NSPredicate(format: record2 = %@, recordTwo.recordID)let sort = NSSortDescriptor(key: ***record2.title2***, ascending: true) //Not sure what I put in between the here. Please help.let query = CKQuery(recordType: Record1, predicate: predicate)query.sortDescriptors = [sort]
Replies
0
Boosts
0
Views
181
Activity
Nov ’15
Possible to sort iCloud query results on field of referenced record?
Say I have the following:Record1title1 : String()record2 : Reference()- This is a reference to Record 2record3 : Reference()- This is a reference to Record 3Record2:title2 : String()If I'm doing a search through Record 1 for references to a particular Record 2 (the relationship between the two records is many-to-many) is it possible to sort my results of the query by title2?I have the following code:let predicate = NSPredicate(format: record2 = %@, recordTwo.recordID)let sort = NSSortDescriptor(key: ***record2.title2***, ascending: true) //Not sure what I put in between the here. Please help.let query = CKQuery(recordType: Record1, predicate: predicate)query.sortDescriptors = [sort]
Replies
0
Boosts
0
Views
224
Activity
Nov ’15
Core Data Objective C
Hello everyone, I have an issue that I cannot figure out, been at it for quite some time now.My goal is to populate a NSMutableArray and save it to core data and retrieve it. My tableview is being populated correctly , i.e. I am using Group and populating the titleForHeaderInSection. But when I terminate the app and try to do a Fetch and cast to an NSMutableArray the data is unreadable and my app is crashing.This is my NSMutableArray *sectionNames , what it looks like after being populated. The NewObject has this in it <Car_Doc_Safe_Plus.CarName: 0x7fc2226cf080> (entity: CarName; id: 0xd000000000080000 <x-coredata:/ carsname = (n Ram,n Jeepn); relationship = nil;This is my Termination when I try to Fetch. *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Car_Doc_Safe_Plus.CarName length]: unrecognized selector sent to instance 0x7fd783ce3130'This is my save to Core Data; My entity is set up to receive NSString , I also tried - transformable - with no luck
Replies
2
Boosts
0
Views
1.5k
Activity
Nov ’15
Disabling Scrolling then Setting ContentOffset in UITextView only makes the text in the top content of TextView visible, how do we make the text in that range visible?
I made a full view DrawBoard class which is inherited from a UITextView class.When the switch on the view controller is on the user can type and scroll, when it is off the user can draw on the Drawboard.@IBAction func changeSwitch(sender: UISwitch) { if sender.on{ drawBoard.setNeedsDisplay() drawBoard.scrollEnabled = true drawBoard.editable = true drawBoard.selectable = true drawBoard.switchBool = false }else if !sender.on { drawBoard.switchBool=true let a:CGPoint = drawBoard.contentOffset drawBoard.scrollEnabled = false drawBoard.setContentOffset(a, animated: false) drawBoard.editable = false drawBoard.selectable=false } }It updates the scrolling but scrollEnabled= false just saves the text that is in the first page range of the textview so that it scrolls to the top automatically and disable the scrolling there.Then when I do the setContentOffset the drawable view of the background is visible and it draws on the right place of the textview. However the text that should be on top of it is not visibl
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
2.2k
Activity
Nov ’15
Reply to Why no Self within structs?
This doesn't compile:class C { var someProperty: Self {return self} }and it's pointless for either to compile:protocol CType {} extension CType { func someMethod() -> Self {return self} var someProperty: Self {return self} }Reference types being tied in with inheritance is a weird overload.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’15
Reply to Why no Self within structs?
This is (at least the beginning of) a great example of why I'm staying away from classes, not to mention inheritance, as much as I possibly can in my code, and in (the topic of) this thread. : )
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’15
Reply to Why no Self within structs?
Inheritance is ridiculous and I expect that it will be deprecated in Swift for non-objc types.protocol ThingType {} extension ThingType { static var name: String {return ThingType} } class Thing: ThingType { static var defaultName: String {return (Thing.self as ThingType.Type).name} static var name = Thing }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’15
Reply to Why no Self within structs?
As the title says: structs (not classes) ... so I repeat:This is (at least the beginning of) a great example of why I'm staying away from classes, not to mention inheritance, as much as I possibly can in my code, and in (the topic of) this thread. : )
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’15
Reply to Why no Self within structs?
I think bob133 gave you the correct answer accidentally. 'Self' as the return type in a class is exactly what 'instancetype' is in Obj-C. It means a class determined by the call site, which may be a subclass of the class of the declaration site of the method. In fact, using the class name instead is semantically different from Self.In structs, without any inheritance, the only possibility is the struct containing the declaration, so you can use the literal name of the type. OTOH, allowing 'Self' would seem to be harmless.As far as protocols are concerned (and classes using Self conforming to protocols using Self), I was not able to find documentation on what it means, the last time I looked.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’15
Xcode unable to compile xcdatamodeld
Hello,Xcode stalls on compiling the xcdatamodeld Core Data file when attempting to build my project.This is only happening (to my knowledge) for this project in particular.The following is shown in the Report Navigator in Xcode, under the target for the App. This is what the compiler endlessly tries to compile.DataModelCompile DerivedData/Unitu/Build/Intermediates/ArchiveIntermediates/Unitu/InstallationBuildProductsLocation/Applications/Unitu.app/ Unitu/UnituAPIDataModel.xcdatamodeld cd /Users/jamesbellamy/Desktop/unitu export PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin /Applications/Xcode.app/Contents/Developer/usr/bin/momc --sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk --iphoneos-deployment-target 8.0 --module Unitu /Users/jamesbellamy/Desktop/unitu/Unitu/UnituAPIDataModel.xcdatamodeld /Users/jamesbe
Replies
1
Boosts
0
Views
865
Activity
Dec ’15
Including code and storage
One problem I have always had with Objective C. and now Swift, is the lack of multiple inheritance. I have certain functionality I would like to add to a number os disparate classes without having to replicate the code. Catagories (and Swift extensions) don't allow storage, and are specific to a particular class. In Objective C, I had considered the use of a simple include file, but I'm not sure it that works in Swift, and am not sure of the implications in debugging. Many classes, eg, views and view controllers, already inherit from other classes, so a common base class is out of the question. Is there any good way to do this?
Replies
8
Boosts
0
Views
406
Activity
Dec ’15
Reply to Including code and storage
I believe that means the (stored) properties have to be defined in the class that adopted the protocol. I have to say that I am confused by protocol extensions. The extension is to the protocol. Is that effectively the same as the class having that extension, and that the etension methods can be called from an object of that class? Then the protocol itself says what must be defined in the class for calls from the extension methods. Do I have that right?One issue is that if i had multiple inheritance, I could define methods which need to be overriden in the new class. But that is not possible with protocols and extensions.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’15