Post not yet marked as solved
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?
Post not yet marked as solved
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.
Check out the arc4random_uniform function.
uint32_t randomNumber = arc4random_uniform(25);
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];
Post not yet marked as solved
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.
Post not yet marked as solved
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?
Post not yet marked as solved
You should be checking for the NSTextField's field editor, because NSTextFields don't become the window's firstResponder even when they have focus (one of the quirks of AppKit). Search about the field editor.
To check if a text field is being edited try using currentEditor property instead like this:
if (someTextField.currentEditor != nil)
{
//editing
}
else
{
//not editing...
}
Post not yet marked as solved
@MyMattes
Thanks for sharing that repository. I wasn't able to get this to build though. I keep getting the following error:
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: MacOSX10.11-x86_64.sdk/lib/libcrypto.a (No such file or directory)
Do you know where I could be going wrong here?
Post not yet marked as solved
It seems if I remove the call to dispatch_async on the main queue in the NSURLSessionDataTaskDelegate method, the BGAppRefreshTask seems to be more reliable. However when dispatching on the main queue the app seems to just simply remain suspended until the app re-enters the foreground.
This is a problem because my app downloads data and must post notifications on the main thread in order for areas in the UI to refresh to reflect the new content. Also my app uses a database, where queries are execute on a particular database queue. And the networking code that downloads data uses its own queue.
So networking queue downloads data -> dispatches to database queue inserts new content -> dispatches to main queue and notifies UI elements of content refresh.
Simply just suspending the app immediately after dispatching to another queue from within a background task is pretty strict and makes composing reusable operations difficult. BGAppRefreshTask in this current form does not seem very usable except for the simplest cases.
Post not yet marked as solved
For some reason if I change the task from BGAppRefreshTask to a BGProcessingTask, and set the BGProcessingTaskRequest’s requiresNetworkConnectivity = YES…the background url session suddenly works when I test the simulate the task from the debugger.
I’ve been unable to get BGAppRefreshTask to work with NSURLSession…even though the documentation states that BGAppRefreshTask is the replacement API for -application: performFetchWithCompletionHandler:
I’m testing on iOS 13.
Post not yet marked as solved
After a lot of frustration, I noticed in Build Settings my project had VALIDARCHS set under "User Defined Build Settings." Not sure if I added this years ago or Xcode automatically added this build setting at some point through the years (this project has been around for awhile).
In any case, deleting the VALIDARCHS Build setting fixed my problem and the app now runs on the simulator. I also had to do this for a couple subprojects.
Post not yet marked as solved
I'm having the exact same issue.
Post not yet marked as solved
I'm having the same problem with a project of mine after updating to Xcode 12, except the "embedded framework" here is one of my own from a subproject.
Framework has Standard architectures set in build settings...trying to run on the iOS simulator, the app won't build. If I switch to an iOS device Build succeeds.
Post not yet marked as solved
I think I might have tracked the issue down.
I have my own asynchronous operation that wraps a CKModifyRecordsOperation inside of it. This is for a single record, so I assumed I could handle the error in the perRecordCompletionBlock or if there's no error to handle...post the KVO notifications for my operation for isExecuting and isFinished.
I had assumed, that the perRecordCompletionBlock would always be called. But that is not the case for some reason. If I get the following error:
"Network Failure" (4/NSURLErrorDomain:-1001); "The request timed out.">
The per record completion block is *never* called and the error must be handled in the modifyRecordsCompletionBlock. So I had an operation basically that never finished (because the perRecordCompletionBlock was never called) and my operation never posted KVO notifications for isExecuting and isFinished and it blocked my queue (which has a maxConcurrentOperationCount set to 1). And syncing stopped working because my queue was blocked. Heh.
So long story short, perRecordCompletionBlock may not always be called for this kind of error as of iOS 13...are errors that skip the perRecordCompletionBlock documented anywhere?
Post not yet marked as solved
Just had around a 10 minute delay before iPad changes made it over to the iPhone. Is this just how it is or is there anything I can do? Delay seems pretty long here. If the app was in the background would be okay, but it is in the foreground.
I really don't want hit the server on a timer.