Discuss Swift.

Swift Documentation

Posts under Swift subtopic

Post

Replies

Boosts

Views

Created

init?(coder: NSCoder) or init?(coder: (NSCoder?))
In this code, I use in some places required init?(coder: (NSCoder?)) { // Init some properties super.init(coder: coder!) } And in other places required init?(coder: NSCoder) { super.init(coder: coder) // Init some properties } Both seem to work. Is there a preferred one ? In which cases ? Or should I always use the second one ? And can super be called at anytime ?
2
0
598
3w
Bridging Header doesn't seem to include my Swift class
I think have done everything by the book. I added a small Swift file to my Objective-C project. This is code in the project, not in a framework, so I did not use the public keyword: import Foundation @objc TestClass: NSObject { @objc init(){} } Adding this file prompted creating a bridging header and it should have added TestClass into it. I added the import to the Objective-C .m file. This didn't produce an error so the file must be there: #import "SoftServePro-Bridging-Header.h" I made a property for an instance of the class in the .h file: @property(nonatomic,strong) TestClass *test; I cleaned the project and did one compile for the precompiler to populate the bridging header. I have set Defines Module to Yes in Build Settings -> Packaging. I added a line in the .m code to create a TestClass: self.test=[[TestClass alloc]init]; And for my trouble I get the error message Now, this looks to me like TestClass is not in my bridging header because if it were it should know exactly what TestClass is, not just consider it a forward declaration. I haven't figured out any way to look at the actual contents of the bridging header after precompile, so I don't know if TestClass is there or not. The ONLY thing that I have not followed is that the documentation I have read says to put the bridging header in the same folder as the .xcodeproj file, but Xcode put it in with all the source code files (one folder down) and who am I to argue with Xcode??
3
0
1.2k
1w
Data Disappeared
Hi, writing a database app for storing equipment details. Spent the day doing minor changes and tidying with many backups made, and always re-building to check its all working. Everything ok but then next build looses all data, what's the best thing to check to see if the data is still there, any help would be fantastic.
1
0
1.1k
1w
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
1
0
116
23h
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
0
0
122
20h
init?(coder: NSCoder) or init?(coder: (NSCoder?))
In this code, I use in some places required init?(coder: (NSCoder?)) { // Init some properties super.init(coder: coder!) } And in other places required init?(coder: NSCoder) { super.init(coder: coder) // Init some properties } Both seem to work. Is there a preferred one ? In which cases ? Or should I always use the second one ? And can super be called at anytime ?
Replies
2
Boosts
0
Views
598
Activity
3w
Bridging Header doesn't seem to include my Swift class
I think have done everything by the book. I added a small Swift file to my Objective-C project. This is code in the project, not in a framework, so I did not use the public keyword: import Foundation @objc TestClass: NSObject { @objc init(){} } Adding this file prompted creating a bridging header and it should have added TestClass into it. I added the import to the Objective-C .m file. This didn't produce an error so the file must be there: #import "SoftServePro-Bridging-Header.h" I made a property for an instance of the class in the .h file: @property(nonatomic,strong) TestClass *test; I cleaned the project and did one compile for the precompiler to populate the bridging header. I have set Defines Module to Yes in Build Settings -> Packaging. I added a line in the .m code to create a TestClass: self.test=[[TestClass alloc]init]; And for my trouble I get the error message Now, this looks to me like TestClass is not in my bridging header because if it were it should know exactly what TestClass is, not just consider it a forward declaration. I haven't figured out any way to look at the actual contents of the bridging header after precompile, so I don't know if TestClass is there or not. The ONLY thing that I have not followed is that the documentation I have read says to put the bridging header in the same folder as the .xcodeproj file, but Xcode put it in with all the source code files (one folder down) and who am I to argue with Xcode??
Replies
3
Boosts
0
Views
1.2k
Activity
1w
Data Disappeared
Hi, writing a database app for storing equipment details. Spent the day doing minor changes and tidying with many backups made, and always re-building to check its all working. Everything ok but then next build looses all data, what's the best thing to check to see if the data is still there, any help would be fantastic.
Replies
1
Boosts
0
Views
1.1k
Activity
1w
Why is the Documentation full of Conundrums?
I'm trying to learn and focus on the task and your examples keep having hidden conundrums in them. Here is an example that got me snagged for hours last night going, Well what the F do they want me to name it? What is it you want me to learn here? Because you pose a giant riddle of name something that you should be given a name for... My friend said to me that this is a common thing you will have to do and they were right however... What are you asking me to do? Get stuck on the variable naming problem where I'm going... Yeah those are math terms from 20+ years ago and I have no idea how to classify those terms... Are you asking me that? No. So why is that in the problem. These conundrums mixed in with legitimate problems honestly make me not want to learn Swift at all.
Replies
1
Boosts
0
Views
116
Activity
23h
Attached macro loses generated source file
I’m seeing what looks like a compiler / macro-expansion / build-pipeline issue. Environment: Xcode 26.4 RC (17E192, latest); I believe it is also reproducible on earlier versions. github source code I reduced this to a very small macOS/iOS app plus a local macro package. The app logic is trivial, but app exits immediately on launch with code 138 Important observations: If I inline everything into a single file, the problem disappears. I also see an error like this during investigation: The file path does not exist on the file system: /var/folders/.../swift-generated-sources/@__swiftmacro_18MacroFeedbackRepro20MountActivationState17PreservedRawValuefMm_.swift That makes me suspect this is not an application logic issue, but something in macro expansion / generated source handling / compiler pipeline.
Replies
0
Boosts
0
Views
122
Activity
20h