Post

Replies

Boosts

Views

Activity

Reply to Swift framework localization
Bundle was the problem. Default bundle is Bundle.main which is App's bundle not the framework bundle. Passing the frameworks bundle fixed the issue. I used Bundle(identifier:) to get the framework's bundle. So the method will look like below. NSLocalizedString("string_key", bundle: Bundle(identifier: "com.framework.bundle") ?? Bundle.main, comment: "Actual String")
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Swift framework localization
Yes, comment parameter is for the development purpose. In the app UI, I see text as "string_key" Localizable.Strings contents will look like below */    Localizable.strings */ "string_key" = "username"; "string_key1" = "password"; "string_key2" = "login";**
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’21
Reply to Pass Data from Swift to SwifUI
This is how I ended up.     var score = "1"     func A () {}          func B () {         // score will get updated frequently         let scoreModal =  ScoreUIViewModel()         let scoreUI: ScoreUI = ScoreUI(showModal: .constant(true), scoreUIViewModel: scoreModal)         DispatchQueue.main.async {             scoreUI.displayScoreUI()         }        // score getting updated from another class         scoreModal.score = score // score getting updated from another class         score  = "2"         scoreModal.score = "2" // score getting updated from another class         score  = "3"         scoreModal.score = "3" // score getting updated from another class        score  = "4"         scoreModal.score = "4"      .......              } } import SwiftUI class ScoreUIViewModel: Observable {     @Published score: String } struct ScoreUI: View {     @State var scoreUIViewModel: ScoreUIViewModel     func displayScoreUI() {         let hostController = UIHostingController(rootView: ScoreUI())         hostController = .overCurrentContext         topViewController()!.present(hostController, animated: true, completion: nil)     }.environmentObject(scoreUIViewModel)      } struct ScoreText: View {     @EnvironmentObject var scoreUIViewModel: ScoreUIViewModel     Text(score).foregroundColor(.green) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’21
Reply to Present SwiftUI without tap
let swiftUIController = UIHostingController(rootView: ContentView(showModal: .constant(true))) rootController()!.present(swiftUIController, animated: true, completion: nil) Above code works but not sure whether its a best practice.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’21
Reply to Error JSONSerialization
I am facing similar issue.... Error: underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.} Question I know that using using JSONDecoder we can convert the downloaded JSON data into class/struct object. Is there a way to do the same for raw data(NSData)/octect. Since downloaded is not a json, I am getting error. I have class like this Code public struct FileData: Codable{ public var data: Data? public init (data: Data? = nil){ self.data = data } } Is there a way to assign the downloaded data to FileData().data via decoding extension Data { func decode() -> Result<T, Error> where T: Codable { do { let decoder = JSONDecoder() let object: T = try decoder.decode(T.self, from: self)  return Result.success(object) } catch { return Result.failure(error) } } Expectation: Here T is FileData. I using REST Get api to download(octet stream) a file data and want to set it to FileData().data. It seems like raw data can't be Codable? Is that true? If so, I think I need to manually assign the downloaded data to FileData().data
Topic: Programming Languages SubTopic: Swift Tags:
Jun ’21
Reply to Weak references
How to determine whether weak self is required or not.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’21
Reply to I can not see my app build on App store connect
You can check the upload status in Xcode organizer. Go to Windows -> Organizer and see the upload status.
Replies
Boosts
Views
Activity
Jul ’21
Reply to Removing folder from .app
Does exclude source file names works for folders with sub folders
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Swift framework localization
Bundle was the problem. Default bundle is Bundle.main which is App's bundle not the framework bundle. Passing the frameworks bundle fixed the issue. I used Bundle(identifier:) to get the framework's bundle. So the method will look like below. NSLocalizedString("string_key", bundle: Bundle(identifier: "com.framework.bundle") ?? Bundle.main, comment: "Actual String")
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Swift framework localization
Yes, comment parameter is for the development purpose. In the app UI, I see text as "string_key" Localizable.Strings contents will look like below */    Localizable.strings */ "string_key" = "username"; "string_key1" = "password"; "string_key2" = "login";**
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Semaphore
Ok, what is the best practice other than async/wait as I have to implement before this fall.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Semaphore
Are you saying using semaphores to wait until download is complete a bad practice? If so, can you suggest a good practice?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to DataFlow from Swift to SwfitUI
Yes.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Pass Data from Swift to SwifUI
This is how I ended up.     var score = "1"     func A () {}          func B () {         // score will get updated frequently         let scoreModal =  ScoreUIViewModel()         let scoreUI: ScoreUI = ScoreUI(showModal: .constant(true), scoreUIViewModel: scoreModal)         DispatchQueue.main.async {             scoreUI.displayScoreUI()         }        // score getting updated from another class         scoreModal.score = score // score getting updated from another class         score  = "2"         scoreModal.score = "2" // score getting updated from another class         score  = "3"         scoreModal.score = "3" // score getting updated from another class        score  = "4"         scoreModal.score = "4"      .......              } } import SwiftUI class ScoreUIViewModel: Observable {     @Published score: String } struct ScoreUI: View {     @State var scoreUIViewModel: ScoreUIViewModel     func displayScoreUI() {         let hostController = UIHostingController(rootView: ScoreUI())         hostController = .overCurrentContext         topViewController()!.present(hostController, animated: true, completion: nil)     }.environmentObject(scoreUIViewModel)      } struct ScoreText: View {     @EnvironmentObject var scoreUIViewModel: ScoreUIViewModel     Text(score).foregroundColor(.green) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to Present SwiftUI without tap
let swiftUIController = UIHostingController(rootView: ContentView(showModal: .constant(true))) rootController()!.present(swiftUIController, animated: true, completion: nil) Above code works but not sure whether its a best practice.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’21
Reply to "content-length" unavailable when Transfer-Encoding type is Chunked
Thank you. Is there any other transfer encoding recommended so that I can get content-length?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Error JSONSerialization
I am facing similar issue.... Error: underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.} Question I know that using using JSONDecoder we can convert the downloaded JSON data into class/struct object. Is there a way to do the same for raw data(NSData)/octect. Since downloaded is not a json, I am getting error. I have class like this Code public struct FileData: Codable{ public var data: Data? public init (data: Data? = nil){ self.data = data } } Is there a way to assign the downloaded data to FileData().data via decoding extension Data { func decode() -> Result<T, Error> where T: Codable { do { let decoder = JSONDecoder() let object: T = try decoder.decode(T.self, from: self)  return Result.success(object) } catch { return Result.failure(error) } } Expectation: Here T is FileData. I using REST Get api to download(octet stream) a file data and want to set it to FileData().data. It seems like raw data can't be Codable? Is that true? If so, I think I need to manually assign the downloaded data to FileData().data
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Decoding Downloaded Data
How to achieve via codable?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Decoding Downloaded Data
Ok, Is there any way to assign the downloaded to the instance variable of a class via Codable?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21
Reply to Decoding Downloaded Data
Ok, Is. there a way to assign the downloaded data to the instance variable of a class via Codable?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jun ’21