Objective-C

RSS for tag

Objective-C is a programming language for writing iOS, iPad OS, and macOS apps.

Posts under Objective-C tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Memory management issue while Call Obj-C in Swift
I'm currently developing a native plugin for a Capcitor app. I have very little experience with native iOS development, Swift and Obj-C. I use a framework (FunSDK) which is written in C++. I call this in an Objective-C++ wrapper. As described here: https://medium.com/@cecilia.humlelu/set-up-c-library-dependencies-in-swift-projects-5dc2ccd2ddaf The wrapper is then available in Swift via the bridging header. This works so far, I can call the functions from the framework and they are executed correctly. However, the functions of the framework are executed asynchronously. When a result is obtained, the “OnFunSDKResult” method is always executed. During this step I get an EXC_BAD_ACCESS error while debugging. Then I ticked “Zombie objects” under the diagnostics settings. This causes execution to stop with an EXC_BREAKPOINT. As I understand it, after executing the iniXMSDK method, the FunSDKWrapper class is cleared from memory before executing the "OnFunSDKResult" method? I have also already integrated a completionHandler, which is only called in the "OnFunSDKResult" method so that data is transferred to the Swift class. However, that doesn't help either. I have no idea how to proceed. I hope somebody can help me. If you need any more information, I would be happy to provide it. The FunSDKWrapper.mm // // FunSDKWrapper.m // App // // Created by Sysprobs on 12/8/23. // #import "FunSDKWrapper.h" #import "FunSDK/FunSDK.h" #import <XMNetInterface/Reachability.h> @implementation FunSDKWrapper -(NSString *)iniXMSDK:(int)test completion:(void (^)(int result))completionHandler{ self.initCompletionHandler = completionHandler; self.msgHandle = FUN_RegWnd((__bridge void *)self); FUN_Init(); Fun_LogInit(self.msgHandle, "", 0, "", LOG_UI_MSG); FUN_XMCloundPlatformInit("***", "***", "***", 1); FUN_InitNetSDK(); FUN_SetFunStrAttr(EFUN_ATTR_SAVE_LOGIN_USER_INFO,SZSTR([self GetDocumentPathWith:@"UserInfo.db"])); FUN_SetFunStrAttr(EFUN_ATTR_USER_PWD_DB, SZSTR([self GetDocumentPathWith:@"password.txt"])); FUN_SetFunStrAttr(EFUN_ATTR_UPDATE_FILE_PATH,SZSTR([self GetDocumentPathWith:@""])); FUN_SetFunStrAttr(EFUN_ATTR_TEMP_FILES_PATH,SZSTR([self GetDocumentPathWith:@""])); FUN_SetFunIntAttr(EFUN_ATTR_AUTO_DL_UPGRADE, 0); FUN_SetFunStrAttr(EFUN_ATTR_CONFIG_PATH,SZSTR([self GetDocumentPathWith:@"APPConfigs"])); FUN_SetFunIntAttr(EFUN_ATTR_SUP_RPS_VIDEO_DEFAULT, 1); FUN_SetFunIntAttr(EFUN_ATTR_SET_NET_TYPE, [self getNetworkType]); FUN_SysInit("arsp.xmeye.net;arsp1.xmeye.net;arsp2.xmeye.net", 15010); FUN_InitNetSDK(); FUN_SysGetDevList(self.msgHandle, SZSTR(@"xxxx") , SZSTR(@"xxxx"),0); return @"test"; } - (void)searchLanDevices { FUN_DevSearchDevice(self.msgHandle, 4000, 0); } // NSDocument/fileName - (NSString *)GetDocumentPathWith:(NSString *) fileName { NSString* path = [self documentsPath]; if (fileName != nil) { path = [path stringByAppendingString:@"/"]; path = [path stringByAppendingString:fileName]; } return path; } //NSDocument - (NSString *)documentsPath { NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [pathArray lastObject]; return path; } -(int)getNetworkType { Reachability*reach=[Reachability reachabilityWithHostName:@"www.apple.com"]; //判断当前的网络状态 switch([reach currentReachabilityStatus]){ case ReachableViaWiFi: return 1; case ReachableViaWWAN: return 2; default: return 0; break; } } - (void)OnFunSDKResult:(NSNumber *) pParam { NSInteger nAddr = [pParam integerValue]; MsgContent *msg = (MsgContent *)nAddr; switch (msg->id) { case EMSG_SYS_GET_DEV_INFO_BY_USER:{ self.initCompletionHandler(1); if (msg->param1 < 0){ //fehler NSLog(@"Fehler beim XMCloud login"); }else{ char devJson[750*500]; FUN_GetFunStrAttr(EFUN_ATTR_GET_USER_ACCOUNT_DATA_INFO, devJson, 750*500); NSLog(@"Geraeteliste: = %s",devJson); } } break; } } @end The Swift Class import Foundation import Capacitor /** * Please read the Capacitor iOS Plugin Development Guide * here: https://capacitorjs.com/docs/plugins/ios */ @objc(xmsdkPlugin) public class xmsdkPlugin: CAPPlugin { private let implementation = xmsdk() @objc func echo(_ call: CAPPluginCall) { let value = call.getString("value") ?? "" call.resolve([ "value": implementation.echo(value) ]) } @objc func initXMSDK(_ call: CAPPluginCall) { //let devId = call.getString("devId") ?? "" let wrapper = FunSDKWrapper(); let resp = wrapper.iniXMSDK(1, completion: {(result) -> Void in NSLog("Completion von iniXMSDK") }); call.resolve([ "status": resp ]) } } Errorlog with EXC_BREAKPOINT:
1
0
326
Dec ’23
openpty && security server
hi, I am using the openpty function in my code to run an interactive command, for example, "hdiutil convert -format UDRO /tmp/myFileName.sparsebundle -o ./test". The file myFileName.sparsebundle is an encrypted disk with a password. When running this command, it triggers the security server and a password input dialog box pops up. I don't want this dialog box to appear, and I want to provide the password through the fd_master returned by openpty. How can I achieve this?
1
0
447
Dec ’23
TLS1.3 connection Restriction
I created one application using Websocket when TLS version was 1.2 connection establishment working fine but when server team update TLS1.2 to TLS1.3 due to security enhancement in my project i am getting SSL Handshake fails with code 9836. and NSOSStatusErrorDomain with code 9836. here is my info.plist NSAppTransportSecurity NSAllowsArbitraryLoads NSExceptionDomains myserver.com NSIncludesSubdomains NSExceptionMinimumTLSVersion TLSv1.3 So my query here is that even if we specify TLSv1.3 for myserver.com as: NSExceptionMinimumTLSVersion TLSv1.3 we want to restrict only to TLS1.3, even if my request fails, how to achieve this?
1
0
383
Dec ’23
EXC_BREAKPOINT (SIGTRAP) on Mac arm64?
I received a crash dump from an ARM64 Mac. I see my code here but from what I can tell it looks like this "crash" occurred during cleanup/quit. One thing that caught my eye here is the symbol __A_WATCHDOG_TIMEOUT_HAS_OCCURRED__ that shows up just before exit. Does this mean the watchdog timeout initiated exit? Can I determine why? Crashed Thread: 13 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x000000019c61427c Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5 Terminating Process: exc handler [60432] ... Thread 13 Crashed: 0 FrontBoardServices 0x000000019c61427c -[FBSMainRunLoopSerialQueue assertBarrierOnQueue] + 144 (FBSSerialQueue.m:264) 1 FrontBoardServices 0x000000019c5ca91c -[FBSScene detachLayer:] + 44 (FBSScene.m:222) 2 UIKitCore 0x00000001b59c0538 -[_UIFBSSceneSubstrate detachContext:] + 92 (_UIFBSSceneSubstrate.m:74) 3 UIKitCore 0x00000001b5569168 __UIContextBinderDetachContext + 240 (_UIContextBinder.m:367) 4 UIKitCore 0x00000001b5569014 -[_UIContextBinder detachBindable:] + 192 (_UIContextBinder.m:149) 5 UIKitCore 0x00000001b5568ed0 -[UIWindowScene _windowUpdatedVisibility:] + 84 (UIWindowScene.m:1162) 6 UIKitCore 0x00000001b5568d38 -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 192 (UIWindow.m:2330) 7 UIKitCore 0x00000001b55b9ae8 -[UIWindow _setHidden:forced:] + 104 (UIWindow.m:2556) 8 SDL2 0x00000001026ccb6c 0x102660000 + 445292 9 SDL2 0x0000000102713828 SDL_DestroyWindow + 164 10 My App 0x0000000102073890 cleanup + 60 (init.c:129) 11 libsystem_c.dylib 0x0000000186ddcfa8 __cxa_finalize_ranges + 492 (atexit.c:292) 12 libsystem_c.dylib 0x0000000186ddcd20 exit + 44 (exit.c:78) 13 UIKitMacHelper 0x000000019fbb60ec __A_WATCHDOG_TIMEOUT_HAS_OCCURRED__ + 192 (UINSLifecycleWatchdog.m:35) 14 UIKitMacHelper 0x000000019fbb487c __60-[UINSLifecycleWatchdog initWithStateIdentifier:andTimeout:]_block_invoke + 1160 (UINSLifecycleWatchdog.m:77) 15 UIKitMacHelper 0x000000019fbb5828 run_watchdog_thread + 276 (UINSLifecycleWatchdog.m:305) 16 libsystem_pthread.dylib 0x0000000186f1d034 _pthread_start + 136 (pthread.c:904) 17 libsystem_pthread.dylib 0x0000000186f17e3c thread_start + 8 (:-1)
1
0
606
Dec ’23
How read image file metadata?
I want to read metadata of image files such as copyright, author etc. I did a web search and the closest thing is CGImageSourceCopyPropertiesAtIndex: - (void)tableViewSelectionDidChange:(NSNotification *)notif { NSDictionary* metadata = [[NSDictionary alloc] init]; //get selected item NSString* rowData = [fileList objectAtIndex:[tblFileList selectedRow]]; //set path to file selected NSString* filePath = [NSString stringWithFormat:@"%@/%@", objPath, rowData]; //declare a file manager NSFileManager* fileManager = [[NSFileManager alloc] init]; //check to see if the file exists if ([fileManager fileExistsAtPath:filePath] == YES) { //escape all the garbage in the string NSString *percentEscapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)filePath, NULL, NULL, kCFStringEncodingUTF8); //convert path to NSURL NSURL* filePathURL = [[NSURL alloc] initFileURLWithPath:percentEscapedString]; NSError* error; NSLog(@"%@", [filePathURL checkResourceIsReachableAndReturnError:error]); //declare a cg source reference CGImageSourceRef sourceRef; //set the cg source references to the image by passign its url path sourceRef = CGImageSourceCreateWithURL((CFURLRef)filePathURL, NULL); //set a dictionary with the image metadata from the source reference metadata = (NSDictionary *)CGImageSourceCopyPropertiesAtIndex(sourceRef,0,NULL); NSLog(@"%@", metadata); [filePathURL release]; } else { [self showAlert:@"I cannot find this file."]; } [fileManager release]; } Is there any better or easy approach than this?
1
0
621
Dec ’23
Digital signature to PDF file on Swift/Objective-C
Hi there, Currently, I'm assigned to do the task that allow user can sign their digital signature on iPhone. I've researched for a week and so far, I'm lost on my way. I want to ask your all experience in working the similar task. My demand is: Allow users upload PDF document Then, allow users sign their digital signature Please give me a logic, step and how it works programmatically to research, in order to do this task. Thank you all <3
1
0
341
Dec ’23
*** Assertion failure in -[_UISystemBackgroundView _internalSubviewsOfType:], _UISystemBackgroundView.m:133
Our application was working fine in iOS 16, but after upgrading to iOS 17.1.1, we see a 100% reproducible crash when generating a cell in the [UITableViewDataSource tableView: cellForRowAtIndexPath:] callback for a particular table. I've only found a single table so far where it crashes. This is the line of code where it crashes: ItemContentTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath]; The crash occurs on the first call. Since it only crashes in this one table, I imagine it's somehow related to the particulars of the cell content layout, but as far as I can see, there's nothing spectacular going on there. Any ideas?? Thanks.
4
0
539
Dec ’23
Download content of public.file-url when Finder does the paste action
Hello, Is it possible fill NSpastebard with public.file-url which will initially point the an empty file. And when Finder will paste the file, my Application will download it and Finder will wait for the completion of the download. My goal is not to use drag &amp; drop. I saw that Microsoft RDP client is doing file download using this way. But I don't know how it works. Empty file is created in sandbox.
2
0
295
Nov ’23
Weird problem of NSTableView with auto layout
I have had this issue for a long time. If I configure any auto layout constraints in TableViewCell, I get extremely weird layout behavior in IB designer; however, layout is completely good during runtime. For example, with a completely new project and a single NSTableView on the main view, I get: If I resize main view, the tableview won't get resized Every time I reopen the project, the tableview would shrink by height. It seems the shrinked height is doubled every time. For example, in the following screenshot, the gap is 56. Next reopen will double the gap to 112. Is this a known bug? I would want to file bug report at https://feedbackassistant.apple.com.
1
1
469
Nov ’23
Accessibility permission corrupted AXWebArea not found
I have an application that uses Accessibility APIs to determine if a browser tab with website content is present by checking for the AXWebArea role element. However, some users have reported that the app is not working after a recent update. When I check for permission using the following code, the result is YES, but the app still cannot detect the AXWebArea element in the browser though other elements like AXButton were there: NSDictionary *options = @{(__bridge id)kAXTrustedCheckOptionPrompt : @YES}; NSLog(@“%d”, AXIsProcessTrustedWithOptions((__bridge CFDictionaryRef)options)); The issue is resolved when the app is removed and re-added to the Accessibility permissions list in the System settings. I would appreciate a detailed explanation of what could be causing this issue.
1
1
768
Dec ’23
Does XCode Cloud not support Obj-c runtime flags?
When building/archiving a mixed Obj-C/Swift app from an XCode Cloud Workflow, it seems that the GCC_PREPROCESSOR_DEFINITIONS (Preprocessor Macros) are not used. We use them for environment switching based on scheme and we'd like to send a test build to Testflight through XCode Cloud for internal testing. If this is the case, is the only option to rewrite code to use Swift Active Compilation Conditions?
1
0
407
Nov ’23
SKPaymentTransaction With Transaction State Incorrect
Hi, I'm receiving an incorrect returning state from SKPaymentTransaction. I have a subscription plan that users can purchase and have access to new features in my app, but, for some reason, even if it's a new app account or new appstore account, when it reaches the SKPaymentTransaction.TransactionState, it always says that the state is SKPaymentTransactionStatePurchased. This code haven't been changed since 2018 and this error started about 1 week ago. This is the full code: - (void)createPaymentWithProduct:(SKProduct *)product { SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product]; payment.quantity = 1; [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] addPayment:payment]; } - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { // Call the appropriate custom method for the transaction state. case SKPaymentTransactionStatePurchasing: [self purchasingTransaction:transaction]; break; case SKPaymentTransactionStateDeferred: [self failedTransaction:transaction]; break; case SKPaymentTransactionStateFailed: [self failedTransaction:transaction]; break; case SKPaymentTransactionStatePurchased: { //It reaches this case but never reaches Purchasing [self purchasedTransaction:transaction]; break; } case SKPaymentTransactionStateRestored: [self restoredTransaction:transaction]; break; default: // For debugging NSLog(@"Unexpected transaction state %@", @(transaction.transactionState)); [self failedTransaction:transaction]; break; } } } After the queue, it calls this functions that ask for the payment receipt, which returns me an error because it's not purchased, so it doesn't have a receipt. - (void)purchasedTransaction:(SKPaymentTransaction *)transaction { [self sendReceiptToServerForTransaction:transaction]; if (self.purchasedNotification) { self.purchasedNotification(); } }
0
0
401
Nov ’23
iOS 17.0.3 UIDocumentInteractionController print crash
PDF is successfully open in UIDocumentInteractionController but when I tap on share &gt; Print button then app crashes only in iOS 17.0.3 (not tried in iOS 17). It is working fine in iOS 15.8. Crash report "termination" : {"flags":0,"code":6,"namespace":"SIGNAL","indicator":"Abort trap: 6","byProc":"PocketRetail","byPid":341}, "ktriageinfo" : "VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter\nVM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter\nVM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter\nVM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter\nVM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter\n", "asi" : {"libsystem_c.dylib":["abort() called"]}, "lastExceptionBacktrace" : [{"imageOffset":972256,"symbol":"__exceptionPreprocess","symbolLocation":164,"imageIndex":22},{"imageOffset":179200,"symbol":"objc_exception_throw","symbolLocation":60,"imageIndex":20},{"imageOffset":1516452,"symbol":"-[NSException initWithCoder:]","symbolLocation":0,"imageIndex":22},{"imageOffset":80840,"symbol":"-[UIViewController __supportedInterfaceOrientations]","symbolLocation":808,"imageIndex":24},{"imageOffset":7131796,"symbol":"-[_UIFullscreenPresentationController _prepareForMixedOrientationTransitionIfNecessaryInWindow:fromViewController:toViewController:]","symbolLocation":448,"imageIndex":24},{"imageOffset":7131100,"symbol":"-[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:]","symbolLocation":932,"imageIndex":24},{"imageOffset":562208,"symbol":"-[UIPresentationController _presentWithAnimationController:inWindow:interactionController:target:didFinish:]","symbolLocation":524,"imageIndex":24},{"imageOffset":7825936,"symbol":"-[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:]","symbolLocation":1156,"imageIndex":24},{"imageOffset":7836224,"symbol":"-[UIViewController _presentViewController:withAnimationController:completion:]","symbolLocation":3284,"imageIndex":24},{"imageOffset":7838832,"symbol":"__63-[UIViewController _presentViewController:animated:completion:]_block_invoke","symbolLocation":92,"imageIndex":24},{"imageOffset":7839596,"symbol":"-[UIViewController _performCoordinatedPresentOrDismiss:animated:]","symbolLocation":484,"imageIndex":24},{"imageOffset":7838680,"symbol":"-[UIViewController _presentViewController:animated:completion:]","symbolLocation":188,"imageIndex":24},{"imageOffset":7839784,"symbol":"-[UIViewController presentViewController:animated:completion:]","symbolLocation":164,"imageIndex":24},{"imageOffset":299640,"symbol":"-[UIPrintPanelViewController presentPrintPanelAnimated:hostingScene:]","symbolLocation":944,"imageIndex":31},{"imageOffset":25464,"symbol":"__80-[UIPrintInteractionController _presentAnimated:hostingScene:completionHandler:]_block_invoke_2","symbolLocation":204,"imageIndex":31},{"imageOffset":68892,"symbol":"-[UIPrintInteractionController _ensurePDFIsUnlockedFirstAttempt:completionHandler:]","symbolLocation":384,"imageIndex":31},{"imageOffset":24440,"symbol":"-[UIPrintInteractionController _presentAnimated:hostingScene:completionHandler:]","symbolLocation":620,"imageIndex":31},{"imageOffset":460048,"symbol":"-[UIPrintActivity performActivity]","symbolLocation":272,"imageIndex":32},{"imageOffset":449908,"symbol":"-[SHSheetActivityPerformer _performPresentationWithViewController:]","symbolLocation":452,"imageIndex":32},{"imageOffset":1218716,"symbol":"-[UIPresentationController transitionDidFinish:]","symbolLocation":1096,"imageIndex":24},{"imageOffset":1217384,"symbol":"__56-[UIPresentationController runTransitionForCurrentState]_block_invoke.111","symbolLocation":336,"imageIndex":24},{"imageOffset":1216900,"symbol":"-[_UIViewControllerTransitionContext completeTransition:]","symbolLocation":116,"imageIndex":24},{"imageOffset":544956,"symbol":"__UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__","symbolLocation":36,"imageIndex":24},{"imageOffset":542804,"symbol":"-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]","symbolLocation":624,"imageIndex":24},{"imageOffset":540364,"symbol":"-[UIViewAnimationState sendDelegateAnimationDidStop:finished:]","symbolLocation":436,"imageIndex":24},{"imageOffset":418968,"symbol":"-[UIViewAnimationState animationDidStop:finished:]","symbolLocation":196,"imageIndex":24},{"imageOffset":419244,"symbol":"-[UIViewAnimationState animationDidStop:finished:]","symbolLocation":472,"imageIndex":24},{"imageOffset":468844,"symbol":"run_animation_callbacks(void*)","symbolLocation":132,"imageIndex":33},{"imageOffset":17152,"symbol":"_dispatch_client_callout","symbolLocation":20,"imageIndex":21},{"imageOffset":76184,"symbol":"_dispatch_main_queue_drain","symbolLocation":984,"imageIndex":21},{"imageOffset":75184,"symbol":"_dispatch_main_queue_callback_4CF","symbolLocation":44,"imageIndex":21},{"imageOffset":227772,"symbol":"__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__","symbolLocation":16,"imageIndex":22},{"imageOffset":214728,"symbol":"__CFRunLoopRun","symbolLocation":1996,"imageIndex":22},{"imageOffset":212504,"symbol":"CFRunLoopRunSpecific","symbolLocation":608,"imageIndex":22},{"imageOffset":13804,"symbol":"GSEventRunModal","symbolLocation":164,"imageIndex":23},{"imageOffset":2290428,"symbol":"-[UIApplication _run]","symbolLocation":888,"imageIndex":24},{"imageOffset":2287928,"symbol":"UIApplicationMain","symbolLocation":340,"imageIndex":24},{"imageOffset":156240,"symbol":"main","symbolLocation":60,"imageIndex":15},{"imageOffset":23876,"symbol":"start","symbolLocation":2104,"imageIndex":25}],
2
1
583
Nov ’23
UITableView Cell is getting focused even when accessibility is disabled in iOS
Accessibility is disabled for tableview cell but it is getting selected.Tableview cell is added as a subview to a view and its accessibility is also disabled.The accessibility value is coming as empty string instead of nil.Imageview is placed inside the tableview cell for that also the accessibility is disabled, still it is getting selected for the cell.Attached the view hierarchy of tableviewcell Sample code: BOOL voiceAccessibility = [screenDelegate getApplicationHasVoiceAccessibility]; if (voiceAccessibility) { if (accEnabled) { [self setIsAccessibilityElement:YES]; if (accLable != nil &amp;&amp; accLable.length &gt;0) [self setAccessibilityLabel:accLable]; } else { [self setIsAccessibilityElement:NO]; self.accessibilityTraits = UIAccessibilityTraitNone; } } Alternative Code tried: -(NSString *)accessibilityLabel{ if([m_acclabel isEqualToString:@""] || m_acclabel == nil || m_acclabel.length == 0){ return nil; } return m_acclabel; } Accessibility Inspector Hierarchy:
0
0
340
Nov ’23
Data(contentsOf:) with huge file
I have a function that computes MD5 hash of a file: func ComputeMD5(ofFile path: String) -&gt; [UInt8]? { if let data = try? Data(contentsOf: URL(fileURLWithPath: path)) { var digest = [UInt8](repeating: 0, count: 16) data.withUnsafeBytes { _ = CC_MD5($0.baseAddress, UInt32(data.count), &amp;digest) } return digest } return nil } Now I wonder/worry what happens if the file is very huge. Does the runtime perform disk memory paging?
2
1
345
Nov ’23
A weird bug to write plist to a file
Recently, I encountered a weird bug that I could not have a clue about. I have an API to save the configuration settings to a plastic, which is located at "/Library/Preferencs/Bitglass". The writer is a daemon and the function looks as follows. The weird thing I found recently was that the function could not save the IPC server port value when the daemon was installed by another installer daemon. But it can save other plastic values without any problems. When the list was not saved to a file, there is not any error messages. The following function is called by two daemons to save different settings into a plastic file. Is there anyone who has any clue why it failed to save the plist to a file when the daemon is installed and launched by another daemon? (BOOL)setValue:(const char *)key value:(const char *)value { std::lock_guardstd::mutex lock(plist_mutex); NSString *nskey = [NSString stringWithUTF8String:key]; NSString *nsval = [NSString stringWithUTF8String:value]; @try { [data setObject:nsval forKey:nskey]; if (![data writeToFile:plistPath atomically:YES]) { BGLOG(LOG_ERROR, "Failed to write" &lt;&lt; key &lt;&lt; "=" &lt;&lt; value); return FALSE; } return TRUE; } @catch (NSException *e) { BGLOG(LOG_ERROR, "Caught exception:" &lt;&lt; [e.name UTF8String] &lt;&lt; " reason:" &lt;&lt; [e.reason UTF8String]); return FALSE; }
1
0
414
Nov ’23