Post

Replies

Boosts

Views

Activity

Reply to Can I use async/await under iOS15.0?
There's some discussion about the same issue on forums.swift.org . Will Swift Concurrency deploy back to older OSs? It seems to be true that the runtime needed for await/async is provided as part of the new OSs. It is a very sad fact that most of us developers need years to adopt this bright and successful new feature. My company follows three-generation policy to support older OSs, which means we can use async/await when iOS 17 will be out. I cannot be sure if I could remember that we could use this feature three years from now. Apple should consider backward compatibility more severely to make this sort of great feature more popular in apps.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Find My unable to connect to server
Please try again later. Have you taken enough time when you tried again? Apple's server related to WWDC may be getting too heavy and some services would not work properly. And anyway, iOS 15 beta is a beta version of a product and it may contain many flaws or bugs. If the issue continues even if you try it later (with enough interval), you should better send a bug report.
Jun ’21
Reply to If statement notification
Isn't this the same question as in your previous post? You should better reply to comments and answers to it before writing a duplicate post.
Jun ’21
Reply to ProgressView Error
As far as I tried, your code shown did not cause the issue you described. (I needed to fill the first line import SwiftUI, but that had nothing to do with the error, I think.) Sometimes, Xcode might show some old bugs which was fixed already. Have you tried Clean Build Folder (Shift-Cmd-K) ? (Or you can choose it from Product menu.)
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Is C similar to Objective-c ?
will learning Objective-c be easy considering that I know C? Syntactically, Objective-C is an extension of C. So, some portion of Objective-C is exactly the same as C. Your experience of C would help learning such aspect of Objective-C. But the core part of Objective-C programming is made of Object Oriented class system, which you cannot find in C. If you do not have any knowledge about Object Oriented Programming, you may find hard difficulties in that part. If you have some knowledge about Smalltalk, it would help understanding OOP parts of Objective-C. Or if you know some OOP languages, such as Java or C#, that would also help learning Objective-C. Conclusion, your knowledge of C would help learning Objective-C, but whether it is easy or not would depend on your other experiences or your way of thinking.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Check on FetchRequest not working
I tried putting the check after the request Seems you put the check after initializing FetchRequest, not after the request. It is hard to predict when exactly the request is made or when the result is updated. One possible solution would be like this: struct TestViewPage: View { var lodgeid: Int @Environment(\.managedObjectContext) var managedObjectContext var lodge: Lodge = getLodgeData() var favourite: Bool {!cdlodges.isEmpty} //<- //this gets the list @FetchRequest var cdlodges: FetchedResults<CDLodge> init(lodgeid: Int) { self.lodgeid = lodgeid self._cdlodges = FetchRequest( entity: CDLodge.entity(), sortDescriptors: [ NSSortDescriptor(keyPath: \CDLodge.lodge, ascending: true), ], predicate: NSPredicate(format: "lodgeid == \(lodgeid)") ) } var body: some View { NavigationView { ScrollView { VStack(alignment: .leading) { VStack { switch favourite { case false: Button(action: { ///save the lodge in core data //... }) { Image("favicon_off") } case true: Button(action: { ///delete the lodge from Core Data //... }) { Image("favicon_on") } } } } .padding() }///end of scrollview .navigationBarTitle("") .navigationBarHidden(true) } //end of navigationview } } With checking favourite dynamically, you would get the result you want. (Though, I omitted favourite = setFav(), which I cannot guess what you want to do with it...)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21
Reply to Sharesheet and iPads
Have you tried this: activityViewController.popoverPresentationController?.sourceView = sender (Assuming sender is a UIButton.) Seems iPadOS cannot find where to show the share sheet when you specify the whole view. By the way, you should better use Code Block rather than Text attachment when you show a code not too long.
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Changing a fetch request
Your code is incomplete, so I cannot test, but can you try something like this: struct EditSocialView: View { @Environment(\.managedObjectContext) var managedObjectContext @Environment(\.presentationMode) var presentationMode var lodge: Lodge = getLodgeData() @State var lodgeId = -1 var body: some View { //... EditSocialList(lodgeId: lodgeId) .onAppear(perform: { self.lodgeId = lodge.id }) //... } } struct EditSocialList: View { var lodgeId: Int //this gets the list @FetchRequest var cdlodges: FetchedResults<CDLodge> init(lodgeId: Int) { self.lodgeId = lodgeId self._cdlodges = FetchRequest( entity: CDLodge.entity(), sortDescriptors: [ NSSortDescriptor(keyPath: \CDLodge.lodge, ascending: true), ], predicate: NSPredicate(format: "lodgeid == \(lodgeId)") ) } var body: some View { //use `cdlodges` here... } } With separating the parts depending on FetchedResults, you may be able to initialize the FetchRequest using lodgeId.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’21