Post

Replies

Boosts

Views

Activity

Reply to how to change view controllers through code on xcode swift
i am currently using this line of code on my logout function What is your logout function? You may need to clarify what view controllers are involved in the situation and name them. once my function has executed Please clarify what is your function. so is there a way to close the opened view controller that was opened?  I think there is. Why don't you use dismiss? By the way, your question has nothing to do with the SwiftUI framework. Using the tag SwiftUI seems to be inappropriate.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Omit items from List without leaving a gap in produced list
Update here is the code: Thanks for showing your code. Seems you are using very unique naming rules. Which is forcing readers make much effort to read your code. You should better improve it, but that's another issue. the list has large gaps in it where other currencies which aren't favourited would normally be. That's the expected result from your code, seems SwiftUI in your environment is working correctly. Why don't you use filter? Something like this: var body: some View { VStack{ HStack{ Toggle("Favourites only", isOn: $showFavs) } Divider() } List { ForEach(items.filter(myFilter)) { record in HStack{ VStack{ HStack{ Text(record.core_Country) Spacer() } HStack(alignment: .center){ Text(FLAGCODES[record.core_Code] ?? "") Text(record.core_Code) Text(record.core_Currency_Name) NavigationLink(destination: CurrencyDetail2(RowData: record)) { } } } } .frame(height: 50) } } .navigationBarTitle(Text("Exchange Rates"), displayMode: .inline) .listStyle(DefaultListStyle()) .navigationBarItems(trailing: Image(systemName:"antenna.radiowaves.left.and.right").resizable() .foregroundColor(FetchedRates.dataStatus)) } func myFilter(_ record: CURRENCIES) - Bool { return FetchedRates.faves.contains(record.core_Code) && showFavs }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Assistant not opening the correct swift file
can't progress any further until I sort this out? You would never be able to progress any more unless you accept that you cannot go exactly as written in the book. Can you clarify what you have done with your storyboard? You have added a prototype cell into a tableView and set ExploreCell to the Custom Class of it? Or something else? You have no need to use .xib, but one thing sure is that you need to do something else than in the book.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Releasing an App upgrade after changing the underlying technology
We also think it should be OK, but can't find any explicit mention of this kind of use case in any documentation.  You would never find it. Many rules describe what you cannot do, but none of them list up all the things what you can do. You should better mind if your app follows the App Store Review Guidelines and Human Interface Guidelines. Some of the app framework might be violating the guidelines.
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’21
Reply to ITMS-90725: SDK Version Issue - submitting with Xcode 11 before Aprin 26
Is there a chance that my update will be rejected event if it is already pushed to AppStoreConnect? It is not clear what submit means in the Apple's News, so you should better include Submit to Review is included. Even if you have some binaries uploaded to App Store Connect, they need to be built with Xcode 12 to Submit to Review after April 26, 2021.
Apr ’21
Reply to What does 'Extra arguments at positions in call' mean?
So my question is, why am I receiving the above error and what can I do to resolve it? It depends on many things, How tableViewData is declared and used How cellData(opened:title:sectionData) is defined My rough guess is something like this: self.tableViewData = [cellData(opened: false, title: "Item 1", sectionData: [productName, listingPrice, briefDescription, productURL, activeUntil])] If this is not what you want, you may need to show more info.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Cannot find 'application' in scope
I cannot find any declaration of application in your code. You need to explicitly declare it. With another fixes: @IBAction func btnCallClick(_ sender: UIButton) { let application = UIApplication.shared //- if let phoneURL = URL(string: "tel://+46706106310") { if application.canOpenURL(phoneURL) { //- `canOpenURL`, not `canOpenUrl` application.open(phoneURL, options: [:], completionHandler: nil) //- `options:` needed } else { //... } } }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Cannot find 'application' in scope
hmm now the app just crashes when i press the call button i think i still got something in the code? I guess it's a problem of your storyboard setting. From this part of the error message: [Diabell_App.ViewController Call:]: unrecognized selector sent to instance iOS is trying to call a method named Call(_:), not btnCallClick(_:). I guess you first connected the action to method Call(_:) and then renamed it to btnCallClick(_:) only on the swift file. Please remove the action connection on the storyboard and re-connect it to the right method. In some cases, you may need to remove the button on the storyboard before re-connecting the action of it.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Xcode for OS X El Capitan
Is there a version of xcode that works with OS 10.11.6 (El Capitan) Yes, there is. But it is too old. According to the Xcode wiki - https://en.wikipedia.org/wiki/Xcode, the latest version for OS X 10.11.6 is Xcode 8.2.1. It was released nearly 4 years ago, in the era of Swift 3.0. You cannot build App Store apps, you cannot run your app on recent devices through Xcode. And Swift3 is too old to learn, the Swift language has changed drastically since then. If you do not mind such things above, visit the More Downloads page - https://developer.apple.com/download/more/.
Apr ’21
Reply to How do I stop 'The compiler is unable to type-check this expression in reasonable time'
it got rid of the original error Big advance! now I get the error Cannot convert value of type '(inout [Rocket]) -> ()' to expected argument type '([Rocket]) -> ()' on line 45 Having multiple things with the same name may not be good for programming, especially when the code being complex enough. I guess you may need to distinguish the property rockets and closure argument rockets: &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;rocketApiCall().getUsers{ (rockets) in self.rockets = rockets} //<- Please do not miss `self.`
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Generic JSON response from API request
If you want to make your loadData generic and access the property results of decodedResponse, You need to tell that type T has a property named results. For example: struct Response: Codable { &#9;&#9;var results: [Result] } struct Result: Codable { &#9;&#9;var trackId: Int &#9;&#9;var trackName: String &#9;&#9;var collectionName: String } protocol HoldingResults { &#9;&#9;associatedtype R &#9;&#9;var results: [R] {get} } extension Response: HoldingResults {} As you see, the protocol HoldingResults is used to tell Swift that the type conforming to it has a property named results. You can define your loadData using the protocol: &#9;&#9;func loadData<T: Decodable>(model: T.Type, completion: @escaping ([T.R])->Void) &#9;&#9;where T: HoldingResults &#9;&#9;{ &#9;&#9;&#9;&#9;guard let url = URL(string: "https://itunes.apple.com/search?term=taylor+swift&entity=song") else { &#9;&#9;&#9;&#9;&#9;&#9;print("Invalid URL") &#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;let request = URLRequest(url: url) &#9;&#9;&#9;&#9;URLSession.shared.dataTask(with: request) { data, response, error in &#9;&#9;&#9;&#9;&#9;&#9;if let data = data { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;do { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;let decodedResponse = try JSONDecoder().decode(model, from: data) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;DispatchQueue.main.async { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(decodedResponse) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;completion(decodedResponse.results) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;return &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} catch { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(error) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;print("Fetch failed: \(error?.localizedDescription ?? "Unknown error")") &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;.resume() &#9;&#9;} And use it as: &#9;&#9;&#9;&#9;loadData(model: Response.self) { &#9;&#9;&#9;&#9;&#9;&#9;self.results = $0 &#9;&#9;&#9;&#9;} (I replaced if-let-try? to do-try-catch, that's my preference and not required.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21