Dive into the world of programming languages used for app development.

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

How to get a font's enabled state
If I disable a font in font book, how can I get the disabled state? I've used two core text APIs to do this, but neither of them works. Here is my code, the option kCTFontCollectionIncludeDisabledFontsOption does not work and the attribute kCTFontEnabledAttribute always return 1, is there anything wrong with my code, or is there any other valid approach? static CFArrayRef fontDescArray; static CFIndex fontCount = 0; static int currentIndex = 0; CFStringRef keys[] = {kCTFontCollectionIncludeDisabledFontsOption,kCTFontCollectionRemoveDuplicatesOption}; CFTypeRef values[] = {kCFBooleanFalse,kCFBooleanTrue}; CFIndex numValues = 2; CFDictionaryRef options = CFDictionaryCreate((CFAllocatorRef)NULL, (const void**)keys, (const void**)values, numValues, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CTFontCollectionRef availableFonts = CTFontCollectionCreateFromAvailableFonts(options); fontDescArray = CTFontCollectionCreateMatchingFontDescriptors(availableFonts); fontCount = CFArrayGetCount(fontDescArray); CTFontDescriptorRef fontDescRef = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fontDescArray, currentIndex); CFBooleanRef enabled =(CFBooleanRef)CTFontDescriptorCopyAttribute(fontDescRef,kCTFontEnabledAttribute); Boolean result = CFBooleanGetValue(enabled); CFRelease stuffs...
0
0
1.3k
Oct ’22
Is there a way to turn off the new dyld improvements in Xcode 14?
I'm having trouble with websockets. I think this is caused by new dyld improvements (You can check the improvements via this link.). Where can I find linker flags to disable them? Thanks. libsp.dylib`spd_checkin_socket.cold.1: 0x226af4364 <+0>: adrp x8, 141669 0x226af4368 <+4>: adrp x9, 0 > 0x226af436c <+8>: add x9, x9, #0xa3f ; "Linked against modern SDK, VOIP socket will not wake. Use Local Push Connectivity instead" 0x226af4370 <+12>: str x9, [x8, #0x400] -> 0x226af4374 <+16>: brk #0x1
2
1
1.8k
Oct ’22
Can we differentiate Physical Sim and Esim info. received by CTCarrier.
I am currently trying to get the carrier info. from device. If I call -    CTTelephonyNetworkInfo *networkinfo = [[CTTelephonyNetworkInfo alloc] init];   NSDictionary *carriers = networkinfo.serviceSubscriberCellularProviders;   CTCarrier *carrInfo;   for(id key in carriers.allKeys){     carrInfo = carriers[key];     NSLog("%@", carrInfo);   } This gives output - Carrier [name: Airtel, MCC: 208, MNC: 15, ISO Country Code: IN] Carrier [name: Jio, MCC: 210, MNC: 20, ISO Country Code: IN] Bu which is physical sim and which is E-sim, I am not able to differentiate. Also. I read this output can switch, not fixed. So how will I be able to differentiate both the sim.
3
0
2.0k
Sep ’22
why is autoreleasepool releasing objects that were retained?!
Hello! I'm using Core ML to do some machine learning predictions. It seems that I have to put the call to "predictionWithFeatures" in an autoreleasepool block, otherwise it will leak memory like crazy. (This is in a project with ARC turned off.) I need to be able to use the results of the prediction outside of the function that does the predictions. So, no problem, I just 'retain' the object that gets returned, right? Except that the autoreleasepool seems to free the object even though its retain count is 3. (Aside: why is it 3?) If anybody can tell me why the autoreleasepool block is freeing objects that have been retained, I would greatly appreciate it. Thank you! Pseudocode below... myCoreMLModelOutput *outputGlobal = NULL; void DoPredictions() { if (outputGlobal != NULL) { [outputGlobal release]; outputGlobal = NULL; } ... @autoreleasepool { // necessary to prevent predictionFromFeatures from leaking memory outputGlobal = [myCoreMLModel predictionFromFeatures ...]; [outputGlobal retain]; // need to be able to access this later printf("retain count: %d\n", (int)[outputGlobal retainCount]); // why is this 3 and not 1 or 2? } DoSomethingWithOutputGlobal(); // crashes ... why was outputGlobal released?! }
5
0
1.5k
Sep ’22
kCGWindowListOptionOnScreenOnly wrong window order
I created an AX observer for kAXMainWindowChangedNotification. In the callback function I call CGWindowListCopyWindowInfo with kCGWindowListOptionOnScreenOnly option to get the id of the current main window (Windows are filtered by PID because I am only interested in the frontmost app). What I experienced is that the received window order reflects the previous state (before the window switch). If I delay the call of CGWindowListCopyWindowInfo with a few milliseconds then the order is perfect but it does not seem to be a stable solution. Is there any other way to wait until every API is notified about the changes then call CGWindowListCopyWindowInfo to get the most recent window information? Subscription: AXUIElementRef appElem = AXUIElementCreateApplication(processId.intValue); CFArrayRef windows; AXError copyResult = AXUIElementCopyAttributeValues(appElem, kAXWindowsAttribute, 0, 1, &windows); AXError createResult = AXObserverCreate(processId.intValue, windowSwitchedCallback, &observer);     if (copyResult != createResult != kAXErrorSuccess) {    return; }   AXObserverAddNotification(observer, appElem, kAXMainWindowChangedNotification, (__bridge void *)(self));   CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop], AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode); Callback: void windowSwitchedCallback(AXObserverRef observer, AXUIElementRef element, CFStringRef notificationName, void *refCon) { if (CFStringCompare(notificationName, kAXMainWindowChangedNotification, 0) == kCFCompareEqualTo) {     NSTimeInterval delayInMSec = 10;     dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInMSec * NSEC_PER_MSEC));     dispatch_after(popTime, dispatch_get_main_queue(), ^(void){       NSDictionary *activeWindow = [(__bridge ActiveWindowObserver*)(refCon) getActiveWindow];       NSLog(@"%@ windowChanged",activeWindow);     });   } } ActiveWindowObserver: - (NSDictionary*) getActiveWindow {   CFArrayRef windowsRef = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);   NSArray *windowsArray = (NSArray *)CFBridgingRelease(windowsRef);   NSPredicate *pIdPredicate = [NSPredicate predicateWithFormat:@"kCGWindowOwnerPID == %@ && kCGWindowLayer == 0", processId];   NSArray *filteredWindows = [windowsArray filteredArrayUsingPredicate:pIdPredicate];   id activeWindow = filteredWindows.count > 0 ? filteredWindows.firstObject : nil;   return activeWindow; }
1
0
1.3k
Aug ’22
macOS System Preferences/Settings plugin using privileged helper (SMJobBless) to update configuration fails
My software is a daemon that is launched via a plist in /Library/LaunchDaemons . Naturally it does not have GUI and other than configuring the runtime during its installation (.pkg) I imagined that creating a System Preferences plugin for my software would allow a privileged user to make changes to the software's runtime configuration. For example the plugin would allow a privileged user to start and stop the daemon. The installer plugin and its helper were setup and signed so that they - in theory - should work together like the SMJobBless examples do. The only difference from examples like EvenBetterAuthorizationSample from what I can tell is that those examples are using a *.app as opposed to a *.prefPane . The SMJobBless error message output to console is: The operation couldn’t be completed. (CFErrorDomainLaunchd error 2.) Is there a limitation in using System Preferences/Settings with SMJobBless?
3
0
1.1k
Aug ’22
IOS app is not starting
I have a React-Native project. This project begun with Expo then it has been ejected switched to react-native. Last week i have updated an expo library that was available in it, i begins to get errors and i was not able to start the project anymore. What i have made, i have removed all expo libraries used, and i have succeeded to start it up on android... But on IOS, it's running without debug problems, but when i start the app it shows the splash screen then it fadeout without starting the first app screen. It seems like onSplashscreen.hide, its not opening the app first screen I think that a person that woks on native language on xcode (swift or objective c) may directly diagnose the problem. Can someone help me with This is my appdelegate.m file #import <React/RCTBridge.h> #import <React/RCTBundleURLProvider.h> #import <React/RCTRootView.h> #import <React/RCTLinkingManager.h> @interface AppDelegate () <RCTBridgeDelegate> @property (nonatomic, strong) NSDictionary *launchOptions; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.launchOptions = launchOptions; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; [self initializeReactNativeApp]; // [super application:application didFinishLaunchingWithOptions:launchOptions]; return YES; } - (RCTBridge *)initializeReactNativeApp { RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return bridge; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #ifdef DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"jsbundle"]; #endif } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { return [RCTLinkingManager application:application openURL:url options:options]; } @end
1
0
2.9k
Aug ’22
Notice user and terminate the program when exit button is pressed. Ask yes or no. Yes to close the app. No to continue the program
Language: Objective C Just like the title, I wanna implement the functionality that can keep user from clicking the exit button by mistake. And it should show some words together like this: "Do you want to close the program?" Button "Yes", Button "No" Is any method I can use? Thank in advance. Where should I put this code?And how to make the actions of those buttons in alert window?
1
0
407
Jul ’22
Application launching to black screen
I am learning to create new apps and somewhere I did something to get my app to now launch to a black screen. I can put a label in the LaunchScreen.storyboard and that displays but the Main.storyboard does not appear. My Main.storyboard has an entry point to a Tab Bar Controller that contains Navigation Controller to 3 ViewControllers. I renamed the app and got TestFlight working with the new app name last night! Today I was looking at CoreData and messed that up. So I tried to remove the xcdatamodeId file and restore it from a time machine backup. Things went bad from there. I think removed and restored the .xcodeproj file with no joy. This happens on both the iPhone and iPad simulator along with my connect iPhone. Anyone have any ideas on what to look at next as I did something(s) dumb here sadly.
1
0
370
Jun ’22
PHPickerViewController shows error every second attempt to display gallery
Our team has implemented PHPickerViewController to allow multiple photos to be selected. It works fine in the simulator but when tested on actual iPad we have this strange behaviour. The first time the gallery is displayed it works fine. If we try and display the gallery again it displays a window with this message “Unable to Load Items - [Try Again]”. If I tap [Try Again] or if I use our Gallery button it does display the gallery. And it keeps cycling through this behaviour. ie. every second attempt to display the gallery leads to the “Unable to Load Items” window.   Every time we display the gallery we dismiss the old instance and create/initialize a new instance of the controller. Our code is written in objective-c… -(void)initPHPickerController     {       [self dismiss];       mPHPickerController = nullref;           PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];       config.selectionLimit = 0; // 0 represents no selection limit.       config.filter = [PHPickerFilter imagesFilter];           config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent;           PHPickerViewController *pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];       pickerViewController.delegate = self;           mPHPickerController = pickerViewController;     }     - (void)dismiss     {       if (mPHPickerController)       {         [+mPHPickerController dismissViewControllerAnimated:YES completion:nil];       }       ...     } Any suggestions on how to fix this ? I have seen a post on stackoverflow that this may be a bug in iOS.
0
0
1.2k
Jun ’22
How to include C++ header file in objective-c++ header
Hello, I am facing a problem in including a C++ header file like vector, set etc. in a objective-c++ header. Lets suppose, I am having 2 files: abc.h abc.mm Now, when I try to include the C++ header in abc.mm file, no build error is coming. But when I try to include the C++ header in abc.h file, it is throwing build error. Build error is: Header not found. How to resolve this error? Any suggestion will be helpful. Thanks Asheesh
4
0
2.9k
Jun ’22
EXC_BAD_INSTRUCTION on dispatch_sync()
The following is my code to show text in textview. But the error, EXC_BAD_INSTRUCTION, happens while executing it. How does this error happen and how could I fix it? dispatch_sync(dispatch_get_main_queue(), ^{ [[[Memo1 textStorage] mutableString]appendString:[NSString stringWithFormat:@"%@", str]]; [Memo1 scrollRangeToVisible:NSMakeRange(Memo1.string.length, 0)];//auto scroll down });
4
0
1.4k
Jun ’22
Thread1: EXE_BAD_INSTRUTION. How does this error show up, I just removed some line that are not important?
I have a button that starts tests. The items, test no, min and max are added to the table_array and refresh table to show them. Following code runs without error. index++; //if([[Elect objectAtIndex:index]isEqualToString:@"1"]) item++; temp = [self GetDCVoltage_34970:1]; if(temp >= [[Min objectAtIndex:index]floatValue] && temp <= [[Max objectAtIndex:index]floatValue]) [table_status addObject:@"Pass"]; else { PF=false; [table_status addObject:@"Fail"]; err=101+item; [errcode setIntValue:err]; } [table_no addObject:[NSString stringWithFormat:@"%d",item]]; [self Show_Datagrid:index]; [table_value addObject:[NSString stringWithFormat:@"%.3f",temp]]; [Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]]; [self refreshTable]; //if (continue_test.state==0 && PF==false) //return; return; After I removed some lines, I only remain the lines that add objects to table_array. Then it shows up error: Thread1: EXE_BAD_INSTRUTION after I pressed button. [table_no addObject:[NSString stringWithFormat:@"%d",item]]; [self Show_Datagrid:index]; [table_value addObject:[NSString stringWithFormat:@"%.3f",temp]]; [Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]]; [self refreshTable];
1
0
522
May ’22
Swift class in ObjC Project : "Receiver 'MySwift' for class message is a forward declaration" error even after adding @obj and open prefixes
After spending a few hours to integrate swift files successfully to my Objective-C based iOS project, I face the next challenge now :In one of my Objective-C class header (Say, MyObjCClass.h), I do the forward declaration for MySwiftClass.In the respective .m file, I define an instance of MySwiftClass _swiftClassInstance.In the init method of MyObjCClass, I try to instantiate it as follows : _swiftClassInstance = [[MySwiftClass alloc] init]; When I compile the code, I get 2 errors :Receiver 'SocketIOClient' for class message is a forward declarationReceiver type 'SocketIOClient' for instance message is a forward declarationI have already done following :Imported MyProject-Swift.h in the MyObjCClass.m file.Marked the swift class with @objc and openSo, what can be the reason for the issue?
3
0
7.9k
May ’22
How to delete WKWebview's Cache in iOS8?
Dear Apple,The requirement of my application is that can delete cache/cookies in WKWebview. I tried somthing and it working as well in iOS 9 upwards. But there are no way to do it in iOS 8. Please let me know if there is a way to remove cache/cookies in iOS 8 or it can not remove?#Note: I want to remove cookies immediately, ie stay at WKWebview but click url to another site it will delete.Thanks,Phong Tran.
2
0
4.5k
May ’22
Get SSID of current network for iOS 15.5
Below snippet is used to fetch SSID of current network. __block NSString *ssid = nil; dispatch_semaphore_t sem = dispatch_semaphore_create(0); [NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {       if( currentNetwork != nil) {         ssid = [currentNetwork SSID];       }       dispatch_semaphore_signal(sem); }]; We are getting proper currentNetwork information in the block. But when ssid is fetched from outside the block, it is getting invalid after the block exits. We are getting bad NSString object. This issue occurs only on iOS 15.5 beta version or later. Same code snippet worked perfectly for earlier versions of iOS. Can you help why it occurs only on iOS 15.5 or later versions? Note: Requirement according to https://developer.apple.com/forums/thread/679038 is fulfilled
3
0
795
Apr ’22
How to get a font's enabled state
If I disable a font in font book, how can I get the disabled state? I've used two core text APIs to do this, but neither of them works. Here is my code, the option kCTFontCollectionIncludeDisabledFontsOption does not work and the attribute kCTFontEnabledAttribute always return 1, is there anything wrong with my code, or is there any other valid approach? static CFArrayRef fontDescArray; static CFIndex fontCount = 0; static int currentIndex = 0; CFStringRef keys[] = {kCTFontCollectionIncludeDisabledFontsOption,kCTFontCollectionRemoveDuplicatesOption}; CFTypeRef values[] = {kCFBooleanFalse,kCFBooleanTrue}; CFIndex numValues = 2; CFDictionaryRef options = CFDictionaryCreate((CFAllocatorRef)NULL, (const void**)keys, (const void**)values, numValues, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CTFontCollectionRef availableFonts = CTFontCollectionCreateFromAvailableFonts(options); fontDescArray = CTFontCollectionCreateMatchingFontDescriptors(availableFonts); fontCount = CFArrayGetCount(fontDescArray); CTFontDescriptorRef fontDescRef = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fontDescArray, currentIndex); CFBooleanRef enabled =(CFBooleanRef)CTFontDescriptorCopyAttribute(fontDescRef,kCTFontEnabledAttribute); Boolean result = CFBooleanGetValue(enabled); CFRelease stuffs...
Replies
0
Boosts
0
Views
1.3k
Activity
Oct ’22
Is there a way to turn off the new dyld improvements in Xcode 14?
I'm having trouble with websockets. I think this is caused by new dyld improvements (You can check the improvements via this link.). Where can I find linker flags to disable them? Thanks. libsp.dylib`spd_checkin_socket.cold.1: 0x226af4364 &lt;+0&gt;: adrp x8, 141669 0x226af4368 &lt;+4&gt;: adrp x9, 0 &gt; 0x226af436c &lt;+8&gt;: add x9, x9, #0xa3f ; "Linked against modern SDK, VOIP socket will not wake. Use Local Push Connectivity instead" 0x226af4370 &lt;+12&gt;: str x9, [x8, #0x400] -&gt; 0x226af4374 &lt;+16&gt;: brk #0x1
Replies
2
Boosts
1
Views
1.8k
Activity
Oct ’22
Can we differentiate Physical Sim and Esim info. received by CTCarrier.
I am currently trying to get the carrier info. from device. If I call -    CTTelephonyNetworkInfo *networkinfo = [[CTTelephonyNetworkInfo alloc] init];   NSDictionary *carriers = networkinfo.serviceSubscriberCellularProviders;   CTCarrier *carrInfo;   for(id key in carriers.allKeys){     carrInfo = carriers[key];     NSLog("%@", carrInfo);   } This gives output - Carrier [name: Airtel, MCC: 208, MNC: 15, ISO Country Code: IN] Carrier [name: Jio, MCC: 210, MNC: 20, ISO Country Code: IN] Bu which is physical sim and which is E-sim, I am not able to differentiate. Also. I read this output can switch, not fixed. So how will I be able to differentiate both the sim.
Replies
3
Boosts
0
Views
2.0k
Activity
Sep ’22
ios 16 "Application circumvented Objective-C runtime dealloc"
When I run the program in Xcode beta4, I get an error with: "Application circumvented Objective-C runtime dealloc",How do I solve this problem
Replies
3
Boosts
2
Views
3.1k
Activity
Sep ’22
why is autoreleasepool releasing objects that were retained?!
Hello! I'm using Core ML to do some machine learning predictions. It seems that I have to put the call to "predictionWithFeatures" in an autoreleasepool block, otherwise it will leak memory like crazy. (This is in a project with ARC turned off.) I need to be able to use the results of the prediction outside of the function that does the predictions. So, no problem, I just 'retain' the object that gets returned, right? Except that the autoreleasepool seems to free the object even though its retain count is 3. (Aside: why is it 3?) If anybody can tell me why the autoreleasepool block is freeing objects that have been retained, I would greatly appreciate it. Thank you! Pseudocode below... myCoreMLModelOutput *outputGlobal = NULL; void DoPredictions() { if (outputGlobal != NULL) { [outputGlobal release]; outputGlobal = NULL; } ... @autoreleasepool { // necessary to prevent predictionFromFeatures from leaking memory outputGlobal = [myCoreMLModel predictionFromFeatures ...]; [outputGlobal retain]; // need to be able to access this later printf("retain count: %d\n", (int)[outputGlobal retainCount]); // why is this 3 and not 1 or 2? } DoSomethingWithOutputGlobal(); // crashes ... why was outputGlobal released?! }
Replies
5
Boosts
0
Views
1.5k
Activity
Sep ’22
__contravariant with NSDictionary * instance?
Is there a way to define a NSDictionary * var or property so that only contravariant of a class are accepted for the key? i.e. something that would look like this: NSDictionary<__contravariant MYSubclass, id> *dictionary; ?
Replies
2
Boosts
0
Views
780
Activity
Sep ’22
kCGWindowListOptionOnScreenOnly wrong window order
I created an AX observer for kAXMainWindowChangedNotification. In the callback function I call CGWindowListCopyWindowInfo with kCGWindowListOptionOnScreenOnly option to get the id of the current main window (Windows are filtered by PID because I am only interested in the frontmost app). What I experienced is that the received window order reflects the previous state (before the window switch). If I delay the call of CGWindowListCopyWindowInfo with a few milliseconds then the order is perfect but it does not seem to be a stable solution. Is there any other way to wait until every API is notified about the changes then call CGWindowListCopyWindowInfo to get the most recent window information? Subscription: AXUIElementRef appElem = AXUIElementCreateApplication(processId.intValue); CFArrayRef windows; AXError copyResult = AXUIElementCopyAttributeValues(appElem, kAXWindowsAttribute, 0, 1, &windows); AXError createResult = AXObserverCreate(processId.intValue, windowSwitchedCallback, &observer);     if (copyResult != createResult != kAXErrorSuccess) {    return; }   AXObserverAddNotification(observer, appElem, kAXMainWindowChangedNotification, (__bridge void *)(self));   CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop], AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode); Callback: void windowSwitchedCallback(AXObserverRef observer, AXUIElementRef element, CFStringRef notificationName, void *refCon) { if (CFStringCompare(notificationName, kAXMainWindowChangedNotification, 0) == kCFCompareEqualTo) {     NSTimeInterval delayInMSec = 10;     dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInMSec * NSEC_PER_MSEC));     dispatch_after(popTime, dispatch_get_main_queue(), ^(void){       NSDictionary *activeWindow = [(__bridge ActiveWindowObserver*)(refCon) getActiveWindow];       NSLog(@"%@ windowChanged",activeWindow);     });   } } ActiveWindowObserver: - (NSDictionary*) getActiveWindow {   CFArrayRef windowsRef = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);   NSArray *windowsArray = (NSArray *)CFBridgingRelease(windowsRef);   NSPredicate *pIdPredicate = [NSPredicate predicateWithFormat:@"kCGWindowOwnerPID == %@ && kCGWindowLayer == 0", processId];   NSArray *filteredWindows = [windowsArray filteredArrayUsingPredicate:pIdPredicate];   id activeWindow = filteredWindows.count > 0 ? filteredWindows.firstObject : nil;   return activeWindow; }
Replies
1
Boosts
0
Views
1.3k
Activity
Aug ’22
macOS System Preferences/Settings plugin using privileged helper (SMJobBless) to update configuration fails
My software is a daemon that is launched via a plist in /Library/LaunchDaemons . Naturally it does not have GUI and other than configuring the runtime during its installation (.pkg) I imagined that creating a System Preferences plugin for my software would allow a privileged user to make changes to the software's runtime configuration. For example the plugin would allow a privileged user to start and stop the daemon. The installer plugin and its helper were setup and signed so that they - in theory - should work together like the SMJobBless examples do. The only difference from examples like EvenBetterAuthorizationSample from what I can tell is that those examples are using a *.app as opposed to a *.prefPane . The SMJobBless error message output to console is: The operation couldn’t be completed. (CFErrorDomainLaunchd error 2.) Is there a limitation in using System Preferences/Settings with SMJobBless?
Replies
3
Boosts
0
Views
1.1k
Activity
Aug ’22
IOS app is not starting
I have a React-Native project. This project begun with Expo then it has been ejected switched to react-native. Last week i have updated an expo library that was available in it, i begins to get errors and i was not able to start the project anymore. What i have made, i have removed all expo libraries used, and i have succeeded to start it up on android... But on IOS, it's running without debug problems, but when i start the app it shows the splash screen then it fadeout without starting the first app screen. It seems like onSplashscreen.hide, its not opening the app first screen I think that a person that woks on native language on xcode (swift or objective c) may directly diagnose the problem. Can someone help me with This is my appdelegate.m file #import <React/RCTBridge.h> #import <React/RCTBundleURLProvider.h> #import <React/RCTRootView.h> #import <React/RCTLinkingManager.h> @interface AppDelegate () <RCTBridgeDelegate> @property (nonatomic, strong) NSDictionary *launchOptions; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.launchOptions = launchOptions; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; [self initializeReactNativeApp]; // [super application:application didFinishLaunchingWithOptions:launchOptions]; return YES; } - (RCTBridge *)initializeReactNativeApp { RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions]; RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return bridge; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #ifdef DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[NSBundle mainBundle] URLForResource:@"index" withExtension:@"jsbundle"]; #endif } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { return [RCTLinkingManager application:application openURL:url options:options]; } @end
Replies
1
Boosts
0
Views
2.9k
Activity
Aug ’22
Notice user and terminate the program when exit button is pressed. Ask yes or no. Yes to close the app. No to continue the program
Language: Objective C Just like the title, I wanna implement the functionality that can keep user from clicking the exit button by mistake. And it should show some words together like this: "Do you want to close the program?" Button "Yes", Button "No" Is any method I can use? Thank in advance. Where should I put this code?And how to make the actions of those buttons in alert window?
Replies
1
Boosts
0
Views
407
Activity
Jul ’22
Showing Recent Issues Undefined symbol: _OBJC_CLASS_$_SPTSessionManager
I'm working a app with spotify ios sdk in objective-c, when y push Analyze throws: Undefined symbol: OBJC_CLASS$_SPTSessionManager In other linker i have -ObjC and $(inherited) but still dont working. Also in valid architectures i have x86_64 armv7s arm64.
Replies
0
Boosts
0
Views
622
Activity
Jul ’22
Application launching to black screen
I am learning to create new apps and somewhere I did something to get my app to now launch to a black screen. I can put a label in the LaunchScreen.storyboard and that displays but the Main.storyboard does not appear. My Main.storyboard has an entry point to a Tab Bar Controller that contains Navigation Controller to 3 ViewControllers. I renamed the app and got TestFlight working with the new app name last night! Today I was looking at CoreData and messed that up. So I tried to remove the xcdatamodeId file and restore it from a time machine backup. Things went bad from there. I think removed and restored the .xcodeproj file with no joy. This happens on both the iPhone and iPad simulator along with my connect iPhone. Anyone have any ideas on what to look at next as I did something(s) dumb here sadly.
Replies
1
Boosts
0
Views
370
Activity
Jun ’22
PHPickerViewController shows error every second attempt to display gallery
Our team has implemented PHPickerViewController to allow multiple photos to be selected. It works fine in the simulator but when tested on actual iPad we have this strange behaviour. The first time the gallery is displayed it works fine. If we try and display the gallery again it displays a window with this message “Unable to Load Items - [Try Again]”. If I tap [Try Again] or if I use our Gallery button it does display the gallery. And it keeps cycling through this behaviour. ie. every second attempt to display the gallery leads to the “Unable to Load Items” window.   Every time we display the gallery we dismiss the old instance and create/initialize a new instance of the controller. Our code is written in objective-c… -(void)initPHPickerController     {       [self dismiss];       mPHPickerController = nullref;           PHPickerConfiguration *config = [[PHPickerConfiguration alloc] init];       config.selectionLimit = 0; // 0 represents no selection limit.       config.filter = [PHPickerFilter imagesFilter];           config.preferredAssetRepresentationMode = PHPickerConfigurationAssetRepresentationModeCurrent;           PHPickerViewController *pickerViewController = [[PHPickerViewController alloc] initWithConfiguration:config];       pickerViewController.delegate = self;           mPHPickerController = pickerViewController;     }     - (void)dismiss     {       if (mPHPickerController)       {         [+mPHPickerController dismissViewControllerAnimated:YES completion:nil];       }       ...     } Any suggestions on how to fix this ? I have seen a post on stackoverflow that this may be a bug in iOS.
Replies
0
Boosts
0
Views
1.2k
Activity
Jun ’22
How to include C++ header file in objective-c++ header
Hello, I am facing a problem in including a C++ header file like vector, set etc. in a objective-c++ header. Lets suppose, I am having 2 files: abc.h abc.mm Now, when I try to include the C++ header in abc.mm file, no build error is coming. But when I try to include the C++ header in abc.h file, it is throwing build error. Build error is: Header not found. How to resolve this error? Any suggestion will be helpful. Thanks Asheesh
Replies
4
Boosts
0
Views
2.9k
Activity
Jun ’22
EXC_BAD_INSTRUCTION on dispatch_sync()
The following is my code to show text in textview. But the error, EXC_BAD_INSTRUCTION, happens while executing it. How does this error happen and how could I fix it? dispatch_sync(dispatch_get_main_queue(), ^{ [[[Memo1 textStorage] mutableString]appendString:[NSString stringWithFormat:@"%@", str]]; [Memo1 scrollRangeToVisible:NSMakeRange(Memo1.string.length, 0)];//auto scroll down });
Replies
4
Boosts
0
Views
1.4k
Activity
Jun ’22
Thread1: EXE_BAD_INSTRUTION. How does this error show up, I just removed some line that are not important?
I have a button that starts tests. The items, test no, min and max are added to the table_array and refresh table to show them. Following code runs without error. index++; //if([[Elect objectAtIndex:index]isEqualToString:@"1"]) item++; temp = [self GetDCVoltage_34970:1]; if(temp >= [[Min objectAtIndex:index]floatValue] && temp <= [[Max objectAtIndex:index]floatValue]) [table_status addObject:@"Pass"]; else { PF=false; [table_status addObject:@"Fail"]; err=101+item; [errcode setIntValue:err]; } [table_no addObject:[NSString stringWithFormat:@"%d",item]]; [self Show_Datagrid:index]; [table_value addObject:[NSString stringWithFormat:@"%.3f",temp]]; [Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]]; [self refreshTable]; //if (continue_test.state==0 && PF==false) //return; return; After I removed some lines, I only remain the lines that add objects to table_array. Then it shows up error: Thread1: EXE_BAD_INSTRUTION after I pressed button. [table_no addObject:[NSString stringWithFormat:@"%d",item]]; [self Show_Datagrid:index]; [table_value addObject:[NSString stringWithFormat:@"%.3f",temp]]; [Test_value replaceObjectAtIndex:index withObject:[NSString stringWithFormat:@"%.3f",temp]]; [self refreshTable];
Replies
1
Boosts
0
Views
522
Activity
May ’22
CGEventPost with Emoji unicode in Monterey
My program is to send Emoji to the active application. It works in Big Sur, but it fails in Monterey.
Replies
6
Boosts
0
Views
1.6k
Activity
May ’22
Swift class in ObjC Project : "Receiver 'MySwift' for class message is a forward declaration" error even after adding @obj and open prefixes
After spending a few hours to integrate swift files successfully to my Objective-C based iOS project, I face the next challenge now :In one of my Objective-C class header (Say, MyObjCClass.h), I do the forward declaration for MySwiftClass.In the respective .m file, I define an instance of MySwiftClass _swiftClassInstance.In the init method of MyObjCClass, I try to instantiate it as follows : _swiftClassInstance = [[MySwiftClass alloc] init]; When I compile the code, I get 2 errors :Receiver 'SocketIOClient' for class message is a forward declarationReceiver type 'SocketIOClient' for instance message is a forward declarationI have already done following :Imported MyProject-Swift.h in the MyObjCClass.m file.Marked the swift class with @objc and openSo, what can be the reason for the issue?
Replies
3
Boosts
0
Views
7.9k
Activity
May ’22
How to delete WKWebview's Cache in iOS8?
Dear Apple,The requirement of my application is that can delete cache/cookies in WKWebview. I tried somthing and it working as well in iOS 9 upwards. But there are no way to do it in iOS 8. Please let me know if there is a way to remove cache/cookies in iOS 8 or it can not remove?#Note: I want to remove cookies immediately, ie stay at WKWebview but click url to another site it will delete.Thanks,Phong Tran.
Replies
2
Boosts
0
Views
4.5k
Activity
May ’22
Get SSID of current network for iOS 15.5
Below snippet is used to fetch SSID of current network. __block NSString *ssid = nil; dispatch_semaphore_t sem = dispatch_semaphore_create(0); [NEHotspotNetwork fetchCurrentWithCompletionHandler:^(NEHotspotNetwork * _Nullable currentNetwork) {       if( currentNetwork != nil) {         ssid = [currentNetwork SSID];       }       dispatch_semaphore_signal(sem); }]; We are getting proper currentNetwork information in the block. But when ssid is fetched from outside the block, it is getting invalid after the block exits. We are getting bad NSString object. This issue occurs only on iOS 15.5 beta version or later. Same code snippet worked perfectly for earlier versions of iOS. Can you help why it occurs only on iOS 15.5 or later versions? Note: Requirement according to https://developer.apple.com/forums/thread/679038 is fulfilled
Replies
3
Boosts
0
Views
795
Activity
Apr ’22