Posts

Post not yet marked as solved
4 Replies
Thanks @polyphonic. A, B, C and D in framework Y is dependent on framework X and vice versa. That’s why l am looking for some kind of container instead of a framework to separate those files from framework X. I tried moving those files in .bundle but it didn’t work either.
Post not yet marked as solved
4 Replies
@Polyphonic You said "you generally need to create a module", I believe you are asking to create a framework or SPM or static library. If not, then how to create the module . I tried creating framework/target/SPM but facing compilation errors due to dependency. I have a framework with 50+ classes and I want to move 4 files outside of this project. Let's say, I have to move Class A,B, C and D out side of the framework. These 4 classes are accesing other few classes from the main framework and more main framework is accessing Class A,B,C and D. So getting compilation error. I want some sort of container(other than folder) to keep those 4 files separate locally and access them in the main framework.
Post not yet marked as solved
2 Replies
I unpaired the connected device as well but still no luck in opening the xcworkspace from Xcode as well as from Finder.
Post not yet marked as solved
2 Replies
Replied In Concurrency
We can implement using NSLock or Semaphore. So need which one is better. shouldnt hardcore the strings within while loop, that’s why l put it in a function
Post not yet marked as solved
12 Replies
You said "My general advice, however, is that you not create such a tiny critical section but rather manage your concurrency at a higher level." Could you please add more context and code snippet if possible?
Post not yet marked as solved
12 Replies
Thanks Quinn, I believe you are suggesting the following implementation. Please correct me if I am wrong. @property (strong, nonatomic) NSMutableArray *data; @end @implementation ThreadSafeArray -(instancetype)init { if (self = [super init]) { } return self; } -(id)peek { __block id result = nil; dispatch_sync(queue, ^{ result = [self.data firstObject] }); return result; } -(NSUInteger)length { __block NSUInteger count = 0; dispatch_sync(queue, ^{ result = [self.data count] }); return count; } -(void)enqueue:(id)datum { dispatch_async(queue, ^{ [NSLock lock]; [self.data addObject:datum] ; [NSLock unlock]; }); }  @end Can we barrier async instead of lock as shown below. @interface ThreadSafeArray() @property (strong, nonatomic) NSMutableArray *data; @property (strong, nonatomic) dispatch_queue_t queue; @end @implementation ThreadSafeArray - (instancetype)init { if (self = [super init]) { queue = dispatch_queue_create("ThreadSafeArray", DISPATCH_QUEUE_CONCURRENT); } return self; } - (id)peek { __block id result = nil; dispatch_sync(queue, ^{ result = [self.data firstObject]; }); return result; } - (NSUInteger)length { __block NSUInteger count = 0; dispatch_sync(queue, ^{ result = [self.data count] }); return count; } - (void)enqueue:(id)datum { dispatch_barrier_async(queue, ^{ [self.data addObject:datum]; }); }  @end
Post not yet marked as solved
8 Replies
Quinn- Can you give a code snippet on how to implement? Thanks!
Post not yet marked as solved
8 Replies
here is the use case. App will send multiple NSURLSession request to download the catalog and will be adding the catalog downloaded from the server to array. App should not display more that 100 catalog/products. If downloaded product count exceeds zero, app should stop adding product to array and app should block add operation. When app deletes the item(s) then add operation should be unblocked as count will be less than 100.
Post not yet marked as solved
12 Replies
Thanks Quinn, I believe you are suggesting the following implementation. Please correct me if I am wrong. @interface ThreadSafeArray() @property (strong, nonatomic) NSMutableArray *data; @end @implementation ThreadSafeArray (instancetype)init { if (self = [super init]) { } return self; } (id)peek { __block id result = nil; dispatch_sync(queue, ^{ result = [self.data firstObject] }); return result; } (NSUInteger)length { __block NSUInteger count = 0; dispatch_sync(queue, ^{ result = [self.data count] }); return count; } (void)enqueue:(id)datum { dispatch_async(queue, ^{ [NSLock lock]; [self.data addObject:datum] ; [NSLock unlock]; }); } @end Can we barrier async instead of lock as shown below. @interface ThreadSafeArray() @property (strong, nonatomic) NSMutableArray *data; @property (strong, nonatomic) dispatch_queue_t queue; @end @implementation ThreadSafeArray (instancetype)init { if (self = [super init]) { queue = dispatch_queue_create("ThreadSafeArray", DISPATCH_QUEUE_CONCURRENT); } return self; } (id)peek { __block id result = nil; dispatch_sync(queue, ^{ result = [self.data firstObject] }); return result; } (NSUInteger)length { __block NSUInteger count = 0; dispatch_sync(queue, ^{ result = [self.data count] }); return count; } (void)enqueue:(id)datum { dispatch_barrier_async(queue, ^{ [self.data addObject:datum] }); } @end
Post not yet marked as solved
12 Replies
No this is not duplicate. Other thread deals with buffer overflow(array count should not exceed). This thread talks about read/write access. When mutablearray is getting updated(add/remove/insert/exchange), the read operation should be blocked and once write operation is complete, then read operation should continue. Atomic property will help to avoid partial but it won't stop reading the array when its getting updated
Post not yet marked as solved
8 Replies
Yes, Array count should not exceed 100. When the count reaches 100, add/insert operation should be blocked until delete operation happens so that buffer overflow will not happen.
Post not yet marked as solved
12 Replies
When a condition satisfies(example buffer overflow), then the insert operation should wait until someone calls delete operation so that buffer will not overflow.
Post not yet marked as solved
8 Replies
I have declared a class with NSMutableArray initialized and two methods to add and remove. The array count should not exceed 100. If some one calls the method to add an item to that array when the count is 100 then that method should wait until the count goes down to 99 . I want to know how to make the addItem operation to wait until the array count goes down from 100 to 99.
Post not yet marked as solved
2 Replies
You can check the upload status in Xcode organizer. Go to Windows -> Organizer and see the upload status.