Post

Replies

Boosts

Views

Activity

How to wait until an object is removed from Array
I have declared an NSMutableArray and the count should not exceed 100. If some one calls addObject method to add an item to that array when the count is 100 then that method call should not be executed until someone removes an item so that count will go down below 100. Can we use semaphore or group dispatch for signaling or mutex/NSLock is recommended.
8
0
1.4k
Sep ’21
Concurrency
What is the best way to print in the order for the given implementation (void) print:(NSString*) str while(true) { NSLog(@“%@”, str); } } [self print:@“123”]; [self print:@“ABC”]; [self print:@“456”]; [self print:@“DEF”]; output should be printing in the order continuously 123 ABC 456 DEF 123 ABC 456 DEF … … …
2
0
747
Oct ’21
Framework split
I wanted to separate a few file from the framework. Let's say I have Class A,B,C,D,E,F,G. I wanted to move Class D and E out of the framework and keep it separate. Creating a new static/dynamic framework/SPM/Target is giving compilation error as Class D and E dependent on other classes. Is there a way to separate Class D and E by putting them in a separate container and import them in the framework?
0
0
530
Sep ’22
Sticky keys on by itself
Sticky key settings including activating it by tapping the shift key 5 times are disabled. However, the sticky key is activated automatically, so macOS behaves like the Shift Key is being pressed. I updated to the latest OS version and logged into safe mode a few times but no help. I verified all the settings related to Sticky keys are disabled Anyone faced this experience. How to stop activating the Sticky keys.
0
0
240
Sep ’24
Objective C protocol implementation in Swift
I have a framework written in Objective-C. My framework is in Swift and imported the 3rd party Objective-C framework in my project. @interface AAAA: NSObject(void)setHandler:(idHandler)handler @end I wanted to implement the Handler protocol in my Swift project. I did like this Class ZXY: NSObject, Handler{ init(){ super.init AAAA.setHandler(self) } // Implemented Handler Protocol optional methods func aaaa(){ } } Handler protocol optional method aaaa never called. Am I missing anything
1
0
1.1k
May ’21
Semaphore
class  a {     b().download ({ data in     }) } class  b{     func download (downloadedData: @escaping (_ data: Data? ) -> Void )  {         c().download()     } } class c {     func download () -> Data {         let semaphore = DispatchSemaphore(value: 0)           NetworkManager().downloadRequest: { (result: Result<Data, Error>) in                                             switch result {                                             case .success(let success)                                                 ......                                              case .failure(let error): .....                                             }                                             semaphore.signal()                                    }                         )         semaphore.wait()         return data     } } Class a initiates the download and class c interacts with network manager to download the data. Class c issues semaphore wait as soon as it sends request to download the data and issues signal when download completes. Is there a way to issue signal from class a when download is in progress. Basically class a should be able to skip wait by issuing signal command
6
0
1.9k
Jul ’21
Swift framework localization
I am trying to localize Swift framework and added a file Localizable.Strings and that file is included in the target but the app that consumes this framework is showing the key not the actual string. NSLocalizedString("string_key", comment: "Actual String") I think issue is related to bundle. Do I need to add bundle parameter to NSLocalizedString? If so what is the bundle parameter value? If bundle is not required then what must be the issue
4
0
3.2k
Jul ’21
Swift files in Bundle
I wanted to move a few .swift files from the framework to different container. I tried creating framework/static-library/SPM to move a few files from the framework but getting compilation errors for the new framework and old framework due to dependancy. I don't want ondemand resource and wanted to keep it local. So I looking for some container to move a few files from framework and load/import them back. I tried moving those files to Settings.bundle but unable to load/import them in the framework? Is there any other way to achieve this?
4
0
1.5k
Sep ’22