Post

Replies

Boosts

Views

Activity

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 NSTextField check if first responder without notification?
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... }
Topic: UI Frameworks SubTopic: AppKit Tags:
Feb ’21
Reply to Recipe for Building OpenSSL static library for Apple Silicon & Intel?
@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?
Topic: App & System Services SubTopic: Hardware Tags:
Jan ’21