Post

Replies

Boosts

Views

Activity

Reply to UINavigationController's interactivePopGestureRecognizer sometimes causes the popped view controller to never be released (memory leak)
Thanks a lot for your response. That was very helpful (not sure why I didn't think of using the memory graph debugger duh)! The leak is caused by UISwipeActionsConfiguration. The view controller that is being leaked has a UITableView and implements the delegate method: -(nullable UISwipeActionsConfiguration*)tableView:(UITableView*)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath*)indexPath So the leak occurs when I start the navigation controller's interactive pop gesture and the table view simultaneously recognizes the gesture and calls the -tableView:leadingSwipeActionsConfigurationForRowAtIndexPath: method and I return a UISwipeActionsConfiguration just before the view controller is popped off the stack via the interactive pop gesture recognizer... The private UISwipeActionController is still holding on to the UISwipeActionsConfiguration, which is holding on to my view controller even after it has been dismissed from the UI, thus causing the leak. Ouch!
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’22
Reply to StoreKit Configuration File: Auto-Renewable Subscriptions Suddenly Stop Working in StoreKit Testing Environment After Awhile
Also to add when this issue happens (suddenly unsubscribed without taking any user interaction) if I go to the "Manage StoreKit Transactions" window in Xcode while my app is running a debug session and view transactions, indeed the latest transaction in the list is "Expired." If I click the "Subscription Options" button it says "Select an Option to Resubscribe." I've taken no user interaction to unsubscribe to the subscription plan I'm currently testing. StoreKit Testing seems to just randomly unsubscribe me from the subscription plan. Anyone else run into this?
Topic: App & System Services SubTopic: StoreKit Tags:
May ’22
Reply to Subscription Renewal Rate in StoreKit Testing for Xcode Not Working For Subscriptions Unless They Are Monthly Subscriptions?
Thanks a lot for the reply. This was helpful. After changing "Monthly renewal rate to every 30 seconds" and making the purchase in the simulator, my weekly renewal subscription code is working. I think it would be nice to be able to set a renewal rate relative to weekly/yearly subscriptions in a more intuitive fashion, but at least this works. The autorenewable subscription code is triggered, but for my weekly subscription, the expiration date is actually not advanced a week into the future. For example here are two expiration date values in the separate in app purchase receipts after a renewal: 2022-05-02 21:23:10 +0000 2022-05-02 21:20:47 +0000 So in my UI I have an area: "Subscription expires on 5/02/22" After each renewal, this UI refreshes. But because the way Storekit testing works the label never actually changes. It would be cool if the expiration date in the receipt refreshed from 5/02/22 to 5/09/22 and so on, which would make a more realistic test environment.
Topic: App & System Services SubTopic: StoreKit Tags:
May ’22
Reply to StoreKit Testing Not Working for Existing macOS App. Receipt Validation Fails and gives me App Sandbox Receipt
This apparently hasn't changed. Xcode 13.2.1 receipt validation fails when I try to verify against the generated public certificate from the StoreKit configuration file. Receipt validation passes when I validate against the Apple root certificate...but then I'm in the sandbox environment and lose the benefits of StoreKit configuration testing.
Topic: App & System Services SubTopic: StoreKit Tags:
Apr ’22
Reply to NSMutableArray does not raise NSRangeException when trying to set an element at the end of the array
The code shown for your array named a should work. You have: NSMutableArray<NSNumber*> *a = @[@(0), @(0), @(0)].mutableCopy; a[3] = @(1); // works, but why? a[4] = @(1); // also works So you have three NSNumbers in an array at index 0, 1, 2. Then you add another number at index 3, which would be the same thing as doing this: [a addObject:@(1)]; I could be wrong but I believe the line in the documentation below is wrong: If index is beyond the end of the array (that is, if index is greater than or equal to the value returned by count), an NSRangeException is raised. I think it should say: If index is beyond the end of the array (that is, if index is greater than the value returned by count), an NSRangeException is raised. The documentation also says: Replaces the object at the index with the new object, possibly adding the object. You probably should file a bug. Either the documentation or the code is wrong but I believe it is the documentation.
Topic: App & System Services SubTopic: General Tags:
Mar ’22
Reply to Memory mapped file: "Cannot allocate memory"
Cool got it. Thanks for the reply. I'm guessing the answer tot his question is no but I'll ask anyway. Is there any API on iOS to detect when an app's address space limit is getting close to being hit? That is, to be notified preemptively before hitting the limit so I can free some, rather than waiting for a ENOMEM to occur..and then freeing up address space?
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to Memory mapped file: "Cannot allocate memory"
Just stumbled upon this in an app I'm working on. I set a symbolic breakpoint on malloc_error_break which ends up getting hit on the following line in my code:    CGImageRef cgImage = CGImageSourceCreateThumbnailAtIndex(imageSource,                                                              0,                                                              (CFDictionaryRef)options); The imageSource above is created via a CGImageSourceCreateWithURL function call. I use this to load images in a table view. All works well, but after scrolling the table view for awhile it appears I hit the address space limit. I don't use mmap directly and after I get CGImage's from above I covert them to UIImage and release it: CFRelease(imageSource); CFRelease(imageProperties);  if (cgImage != NULL)     {         UIImage *uiIMage = [[UIImage alloc]initWithCGImage:cgImage];         CGImageRelease(cgImage);         return uiIMage;     } The returned UIImages are held in a NSCache object. Is it possible that CGImageSourceCreateThumbnailAtIndex is causing me to hit the address space limit? I don't appear to have a memory leak here so I'm not sure why my address space limit would keep accumulating as I continue scrolling the table view. The image source and CGImage are released after converting to a UIImage.
Topic: App & System Services SubTopic: Core OS Tags:
Feb ’22
Reply to NSKeyedArchiver
Did you try using +unarchivedObjectOfClasses:fromData:error: method instead and specify all the classes that may appear in your dictionary in the classes param?  NSError *error = nil;   id rootObject =  [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class],                                                                        [NSData class],                                                                      [NSString class]]] //include whatever classes are in your dictionary                                         fromData:data                                            error:&error];
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
Reply to Pop Up buttons in Interface Builder don't show menu in iOS 15
This API is so weird. I don't know why they didn't just copy the API from NSPopUpButton. You can wire a selector to the menu items in Interface Builder (apparently no target though...) so the items must dig through the responder chain to find something that implements the selector. If you don't wire the selector for each menu item in IB, then the menu won't show up when you tap the button. So bizarre. Not sure if I'm doing something wrong but I also have to manually change the title on the button in the action -(IBAction)popUpButtonAction:(UICommand*)sender { self.mainPopUpbutton.title = sender.title; } Doing the above fixes the button title problem... but next time the button is clicked, the wrong menu item has the checkmark. I tried changing the state in the action method, but that throws an exception: -(IBAction)popUpButtonAction:(UICommand*)sender { self.mainPopUpbutton.title = sender.title;  sender.state = UIMenuElementStateOn; // not allowed.. } Also be careful wiring an UIButton IBOutlet to the pop up button (have to do it in the document outline... if you try to wire it to the button in a storyboard scene it actually wires the UIButton IBOutlet to the UIMenu!) Implementing one of these in a UITableview is awful BTW.
Topic: UI Frameworks SubTopic: UIKit Tags:
Nov ’21
Reply to UINavigationController's interactivePopGestureRecognizer sometimes causes the popped view controller to never be released (memory leak)
Thanks a lot for your response. That was very helpful (not sure why I didn't think of using the memory graph debugger duh)! The leak is caused by UISwipeActionsConfiguration. The view controller that is being leaked has a UITableView and implements the delegate method: -(nullable UISwipeActionsConfiguration*)tableView:(UITableView*)tableView leadingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath*)indexPath So the leak occurs when I start the navigation controller's interactive pop gesture and the table view simultaneously recognizes the gesture and calls the -tableView:leadingSwipeActionsConfigurationForRowAtIndexPath: method and I return a UISwipeActionsConfiguration just before the view controller is popped off the stack via the interactive pop gesture recognizer... The private UISwipeActionController is still holding on to the UISwipeActionsConfiguration, which is holding on to my view controller even after it has been dismissed from the UI, thus causing the leak. Ouch!
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to StoreKit Configuration File: Auto-Renewable Subscriptions Suddenly Stop Working in StoreKit Testing Environment After Awhile
Also to add when this issue happens (suddenly unsubscribed without taking any user interaction) if I go to the "Manage StoreKit Transactions" window in Xcode while my app is running a debug session and view transactions, indeed the latest transaction in the list is "Expired." If I click the "Subscription Options" button it says "Select an Option to Resubscribe." I've taken no user interaction to unsubscribe to the subscription plan I'm currently testing. StoreKit Testing seems to just randomly unsubscribe me from the subscription plan. Anyone else run into this?
Topic: App & System Services SubTopic: StoreKit Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to Subscription Renewal Rate in StoreKit Testing for Xcode Not Working For Subscriptions Unless They Are Monthly Subscriptions?
Thanks a lot for the reply. This was helpful. After changing "Monthly renewal rate to every 30 seconds" and making the purchase in the simulator, my weekly renewal subscription code is working. I think it would be nice to be able to set a renewal rate relative to weekly/yearly subscriptions in a more intuitive fashion, but at least this works. The autorenewable subscription code is triggered, but for my weekly subscription, the expiration date is actually not advanced a week into the future. For example here are two expiration date values in the separate in app purchase receipts after a renewal: 2022-05-02 21:23:10 +0000 2022-05-02 21:20:47 +0000 So in my UI I have an area: "Subscription expires on 5/02/22" After each renewal, this UI refreshes. But because the way Storekit testing works the label never actually changes. It would be cool if the expiration date in the receipt refreshed from 5/02/22 to 5/09/22 and so on, which would make a more realistic test environment.
Topic: App & System Services SubTopic: StoreKit Tags:
Replies
Boosts
Views
Activity
May ’22
Reply to StoreKit Testing Not Working for Existing macOS App. Receipt Validation Fails and gives me App Sandbox Receipt
Here's my Feedback number on this: FB8974649
Topic: App & System Services SubTopic: StoreKit Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to StoreKit Testing Not Working for Existing macOS App. Receipt Validation Fails and gives me App Sandbox Receipt
This apparently hasn't changed. Xcode 13.2.1 receipt validation fails when I try to verify against the generated public certificate from the StoreKit configuration file. Receipt validation passes when I validate against the Apple root certificate...but then I'm in the sandbox environment and lose the benefits of StoreKit configuration testing.
Topic: App & System Services SubTopic: StoreKit Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to NSMutableArray does not raise NSRangeException when trying to set an element at the end of the array
The code shown for your array named a should work. You have: NSMutableArray<NSNumber*> *a = @[@(0), @(0), @(0)].mutableCopy; a[3] = @(1); // works, but why? a[4] = @(1); // also works So you have three NSNumbers in an array at index 0, 1, 2. Then you add another number at index 3, which would be the same thing as doing this: [a addObject:@(1)]; I could be wrong but I believe the line in the documentation below is wrong: If index is beyond the end of the array (that is, if index is greater than or equal to the value returned by count), an NSRangeException is raised. I think it should say: If index is beyond the end of the array (that is, if index is greater than the value returned by count), an NSRangeException is raised. The documentation also says: Replaces the object at the index with the new object, possibly adding the object. You probably should file a bug. Either the documentation or the code is wrong but I believe it is the documentation.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Memory mapped file: "Cannot allocate memory"
Cool got it. Thanks for the reply. I'm guessing the answer tot his question is no but I'll ask anyway. Is there any API on iOS to detect when an app's address space limit is getting close to being hit? That is, to be notified preemptively before hitting the limit so I can free some, rather than waiting for a ENOMEM to occur..and then freeing up address space?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to Memory mapped file: "Cannot allocate memory"
Just stumbled upon this in an app I'm working on. I set a symbolic breakpoint on malloc_error_break which ends up getting hit on the following line in my code:    CGImageRef cgImage = CGImageSourceCreateThumbnailAtIndex(imageSource,                                                              0,                                                              (CFDictionaryRef)options); The imageSource above is created via a CGImageSourceCreateWithURL function call. I use this to load images in a table view. All works well, but after scrolling the table view for awhile it appears I hit the address space limit. I don't use mmap directly and after I get CGImage's from above I covert them to UIImage and release it: CFRelease(imageSource); CFRelease(imageProperties);  if (cgImage != NULL)     {         UIImage *uiIMage = [[UIImage alloc]initWithCGImage:cgImage];         CGImageRelease(cgImage);         return uiIMage;     } The returned UIImages are held in a NSCache object. Is it possible that CGImageSourceCreateThumbnailAtIndex is causing me to hit the address space limit? I don't appear to have a memory leak here so I'm not sure why my address space limit would keep accumulating as I continue scrolling the table view. The image source and CGImage are released after converting to a UIImage.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to Random Numbers
Check out the arc4random_uniform function.   uint32_t randomNumber = arc4random_uniform(25);
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to NSKeyedArchiver
Did you try using +unarchivedObjectOfClasses:fromData:error: method instead and specify all the classes that may appear in your dictionary in the classes param?  NSError *error = nil;   id rootObject =  [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class],                                                                        [NSData class],                                                                      [NSString class]]] //include whatever classes are in your dictionary                                         fromData:data                                            error:&error];
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Pop Up buttons in Interface Builder don't show menu in iOS 15
This API is so weird. I don't know why they didn't just copy the API from NSPopUpButton. You can wire a selector to the menu items in Interface Builder (apparently no target though...) so the items must dig through the responder chain to find something that implements the selector. If you don't wire the selector for each menu item in IB, then the menu won't show up when you tap the button. So bizarre. Not sure if I'm doing something wrong but I also have to manually change the title on the button in the action -(IBAction)popUpButtonAction:(UICommand*)sender { self.mainPopUpbutton.title = sender.title; } Doing the above fixes the button title problem... but next time the button is clicked, the wrong menu item has the checkmark. I tried changing the state in the action method, but that throws an exception: -(IBAction)popUpButtonAction:(UICommand*)sender { self.mainPopUpbutton.title = sender.title;  sender.state = UIMenuElementStateOn; // not allowed.. } Also be careful wiring an UIButton IBOutlet to the pop up button (have to do it in the document outline... if you try to wire it to the button in a storyboard scene it actually wires the UIButton IBOutlet to the UIMenu!) Implementing one of these in a UITableview is awful BTW.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to Using Sign in With Apple on OSX with wkwebview, -> appear native UI, then how can I handle cancel action?
Not sure if this will work, but may be worth a try: Did you try setting the UIDelegate on the WKWebview and seeing if the WKWebview sends a -webViewDidClose: message to its UIDelegate?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’21