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

Posts under General subtopic

Post

Replies

Boosts

Views

Activity

Emulator file scan problem
I tried to find the file inside the ios emulator. When I scan the directory all the time, it finds my Mac Book local directory. I don't know why the external folder is being read by the emulator. Turn it off or Is there any way to access the folder inside the emulator? The code proceeds from a test application written in Objective-C. Here's the code:    if ((dir = opendir("/Users/macAccount")) != nullptr) {     while ((diread = readdir(dir)) != nullptr) {       printf ("target : %s", diread->d_name);     }     closedir (dir);   } ==> result (This is the contents of my account on the macbook.)  .android| DataGripProjects| Public| .ssh| Movies| .vimrc| Applications| .gradle| .Trash| Mon.tar.gz| .npm| ...
1
0
708
Dec ’21
[iOS] Shared Resources for two Apps from the same developer
Is it possible that AppA and AppB which are from the same developer share some local resources on a given device.For instance:Can the data written by App A, be read by App B (through Shared Defaults or any other mechanism)?The following link is to a similar question raised on stackoverlfow. I wanted to be certain thus, raising this question on Apple Dev Forums.https://stackoverflow.com/questions/9079378/shared-resources-for-two-apps-from-the-same-developer
11
0
9.5k
Dec ’21
How detect SDK version
I have the following code:@implementation NSWindow (Coordination) - (NSPoint)convertPointFromScreen:(NSPoint)point { NSRect rect = NSMakeRect(point.x, point.y, 1, 1); return [self convertRectFromScreen:rect].origin; }I get a compiliation warning:Category is implementing a method which will also be implemented by its primary classI know Swift has builtin preprocessor directives to detect SDK version, but don't know how to do this in objc. Any suggestions?
6
0
8.2k
Nov ’21
Unable to get USB bsdname from macOS Monterey 12 Bate4 of Intel processor
I can’t get USB bsdname from macOS Monterey 12 Bate4 of Intel processor: I have use the "IORegistryEntrySearchCFProperty" function to get the bsdName of the io_service_t, It worked fine on macOS Big Sur's M1 and Intel MBP. Also it worked fine on macOS Monterey App M1. But it always returned nil on macOS Monterey Intel MBP. It involves the following code: void getBsdName(io_service_t usbDevice) { CFStringRef bsdName = NULL;         for(int i = 0; i < 500; i++)         {             bsdName = (CFStringRef)IORegistryEntrySearchCFProperty(usbDevice,                                                                    kIOServicePlane,                                                                    CFSTR( kIOBSDNameKey ),                                                                    kCFAllocatorDefault,                                                                    kIORegistryIterateRecursively );             if(!bsdName) {                 // If don't get a bsd name, keep waiting in 5s.                 usleep(10000);                 continue;             }                          printf("[%s]: Found bsd name for device %d.\n”, __func__, usbDevice);             break;         } } Why it happened? Or is there another way to get it?
5
0
2.2k
Nov ’21
pragma mark in Objc organization style
Hi Yesterday I was finishing a project on Objc, and then found a code organization style, and then responsible for this style of colleague B found me and said he kind of thing specification writing, I recommend this kind of not official, for the code neatness and readability requirements, I came here to seek an answer, although this problem does not affect the logic of the code, I still want a standard answer. But I still want a standard answer, before I have searched and asked a lot of people are recommended to write my way, and finally colleagues B also said that I may have problems with this way of writing, so I missed any details? Colleague B's recommended writing style #pragma mark - #pragma mark Initialization My recommended writing style #pragma mark - Initialization Best wishes!
1
0
943
Nov ’21
How to play audio from NSData in a library in Objective C
I'm trying to play an audio content built from NSData inside a library (.a). It works properly when my code is inside an app. But it is not working when in a library, I get no error and no sound playing. NSError * errorAudio = nil; NSError * errorFile; // Clear all cache NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL]; for (NSString *file in tmpDirectory) {     [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL]; } // Set temporary directory and temporary file NSURL * tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES]; NSURL * soundFileURL = [[tmpDirURL URLByAppendingPathComponent:@"temp"] URLByAppendingPathExtension:@"wav"]; [[NSFileManager defaultManager] createDirectoryAtURL:tmpDirURL withIntermediateDirectories:NO attributes:nil error:&errorFile]; // Write NSData to temporary file NSString *path= [soundFileURL path]; [audioToPlay writeToFile:path options:NSDataWritingAtomic error:&errorFile]; if (errorFile) {     // Error while writing NSData } else {     // Init audio player     self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&errorAudio];     if (errorAudio) {         // Audio player could not be initialized     } else {         // Audio player was initialized correctly         [audioPlayer prepareToPlay];         [audioPlayer stop];         [audioPlayer setCurrentTime:0];         [audioPlayer play];     } } I don't check errorFile intros piece of code, but when debugging I can see that value is nil. My header file #import <AudioToolbox/AudioToolbox.h> #import <AVFoundation/AVFoundation.h> @property(nonatomic, strong) AVAudioPlayer * audioPlayer; My m file #import <AudioToolbox/AudioToolbox.h> #import <AVFoundation/AVFoundation.h> @synthesize audioPlayer; I've been checking for dozens of posts but cannot find any solution, it always works properly in an app, but not in a library. Any help would be greatly appreciated.
0
0
1.3k
Nov ’21
Universallinking opening wrong paths
My AASA file contains: { {...} "applinks": { "apps": [], "details": [ { "appIDs": [ "XXXXXXXX.BUNDLEID" // AASA File contains correct values ], "components": [ "/login/" ] } ] } } My App correctly opens when I browse to /login/. However, my App also opens on all other paths aswell. For example /resetPassword/ is also directed to my App with universalLinking, which I don't want, as it should be handled in the Browser. What am I missing? I was sure only /login/ should be directed to the app, and I don't seem to be able to prevent opening the app when navigating to other paths. I have tried returning NO within my continueUserActivity based on the userActivity.webpageURL without success. - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler I have also tried to add NOT * in the components array for the AASA file. Still the App will open when navigating to any path of my domain, regardless of the AASA Files components.
1
0
714
Nov ’21
New Objective-C project: what can't I do?
My next UIKit project will be in Objective-C. You can argue about why and such, but please know that there are idealist reasons for it. Having said that, what are the main things that aren't supported anymore in Objective-C (= only in Swift)? I don't mean language features, but mainly functional stuff like controls or services (eg. in-app purchases).
2
0
921
Oct ’21
Emulator file scan problem
I tried to find the file inside the ios emulator. When I scan the directory all the time, it finds my Mac Book local directory. I don't know why the external folder is being read by the emulator. Turn it off or Is there any way to access the folder inside the emulator? The code proceeds from a test application written in Objective-C. Here's the code:    if ((dir = opendir("/Users/macAccount")) != nullptr) {     while ((diread = readdir(dir)) != nullptr) {       printf ("target : %s", diread-&gt;d_name);     }     closedir (dir);   } ==&gt; result (This is the contents of my account on the macbook.)  .android| DataGripProjects| Public| .ssh| Movies| .vimrc| Applications| .gradle| .Trash| Mon.tar.gz| .npm| ...
Replies
1
Boosts
0
Views
708
Activity
Dec ’21
Create ObjC project with Storyboards in Xcode 13
I'm getting back to coding after a while and I don't see the option to create an ObjC project with Storyboards in Xcode 13. Please tell me how? Thanks Neerav
Replies
2
Boosts
0
Views
732
Activity
Dec ’21
[iOS] Shared Resources for two Apps from the same developer
Is it possible that AppA and AppB which are from the same developer share some local resources on a given device.For instance:Can the data written by App A, be read by App B (through Shared Defaults or any other mechanism)?The following link is to a similar question raised on stackoverlfow. I wanted to be certain thus, raising this question on Apple Dev Forums.https://stackoverflow.com/questions/9079378/shared-resources-for-two-apps-from-the-same-developer
Replies
11
Boosts
0
Views
9.5k
Activity
Dec ’21
About IAP SKProductsRequest crash
I really can't find the reason for the crash.
Replies
1
Boosts
0
Views
641
Activity
Dec ’21
How detect SDK version
I have the following code:@implementation NSWindow (Coordination) - (NSPoint)convertPointFromScreen:(NSPoint)point { NSRect rect = NSMakeRect(point.x, point.y, 1, 1); return [self convertRectFromScreen:rect].origin; }I get a compiliation warning:Category is implementing a method which will also be implemented by its primary classI know Swift has builtin preprocessor directives to detect SDK version, but don't know how to do this in objc. Any suggestions?
Replies
6
Boosts
0
Views
8.2k
Activity
Nov ’21
Any update from Apple on CVE-2021-42574 fix ?
Any update from Apple on CVE-2021-42574 fix ?
Replies
2
Boosts
0
Views
486
Activity
Nov ’21
Unable to get USB bsdname from macOS Monterey 12 Bate4 of Intel processor
I can’t get USB bsdname from macOS Monterey 12 Bate4 of Intel processor: I have use the "IORegistryEntrySearchCFProperty" function to get the bsdName of the io_service_t, It worked fine on macOS Big Sur's M1 and Intel MBP. Also it worked fine on macOS Monterey App M1. But it always returned nil on macOS Monterey Intel MBP. It involves the following code: void getBsdName(io_service_t usbDevice) { CFStringRef bsdName = NULL;         for(int i = 0; i &lt; 500; i++)         {             bsdName = (CFStringRef)IORegistryEntrySearchCFProperty(usbDevice,                                                                    kIOServicePlane,                                                                    CFSTR( kIOBSDNameKey ),                                                                    kCFAllocatorDefault,                                                                    kIORegistryIterateRecursively );             if(!bsdName) {                 // If don't get a bsd name, keep waiting in 5s.                 usleep(10000);                 continue;             }                          printf("[%s]: Found bsd name for device %d.\n”, __func__, usbDevice);             break;         } } Why it happened? Or is there another way to get it?
Replies
5
Boosts
0
Views
2.2k
Activity
Nov ’21
pragma mark in Objc organization style
Hi Yesterday I was finishing a project on Objc, and then found a code organization style, and then responsible for this style of colleague B found me and said he kind of thing specification writing, I recommend this kind of not official, for the code neatness and readability requirements, I came here to seek an answer, although this problem does not affect the logic of the code, I still want a standard answer. But I still want a standard answer, before I have searched and asked a lot of people are recommended to write my way, and finally colleagues B also said that I may have problems with this way of writing, so I missed any details? Colleague B's recommended writing style #pragma mark - #pragma mark Initialization My recommended writing style #pragma mark - Initialization Best wishes!
Replies
1
Boosts
0
Views
943
Activity
Nov ’21
How to play audio from NSData in a library in Objective C
I'm trying to play an audio content built from NSData inside a library (.a). It works properly when my code is inside an app. But it is not working when in a library, I get no error and no sound playing. NSError * errorAudio = nil; NSError * errorFile; // Clear all cache NSArray* tmpDirectory = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL]; for (NSString *file in tmpDirectory) {     [[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL]; } // Set temporary directory and temporary file NSURL * tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES]; NSURL * soundFileURL = [[tmpDirURL URLByAppendingPathComponent:@"temp"] URLByAppendingPathExtension:@"wav"]; [[NSFileManager defaultManager] createDirectoryAtURL:tmpDirURL withIntermediateDirectories:NO attributes:nil error:&amp;errorFile]; // Write NSData to temporary file NSString *path= [soundFileURL path]; [audioToPlay writeToFile:path options:NSDataWritingAtomic error:&amp;errorFile]; if (errorFile) {     // Error while writing NSData } else {     // Init audio player     self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:&amp;errorAudio];     if (errorAudio) {         // Audio player could not be initialized     } else {         // Audio player was initialized correctly         [audioPlayer prepareToPlay];         [audioPlayer stop];         [audioPlayer setCurrentTime:0];         [audioPlayer play];     } } I don't check errorFile intros piece of code, but when debugging I can see that value is nil. My header file #import &lt;AudioToolbox/AudioToolbox.h&gt; #import &lt;AVFoundation/AVFoundation.h&gt; @property(nonatomic, strong) AVAudioPlayer * audioPlayer; My m file #import &lt;AudioToolbox/AudioToolbox.h&gt; #import &lt;AVFoundation/AVFoundation.h&gt; @synthesize audioPlayer; I've been checking for dozens of posts but cannot find any solution, it always works properly in an app, but not in a library. Any help would be greatly appreciated.
Replies
0
Boosts
0
Views
1.3k
Activity
Nov ’21
Universallinking opening wrong paths
My AASA file contains: { {...} "applinks": { "apps": [], "details": [ { "appIDs": [ "XXXXXXXX.BUNDLEID" // AASA File contains correct values ], "components": [ "/login/" ] } ] } } My App correctly opens when I browse to /login/. However, my App also opens on all other paths aswell. For example /resetPassword/ is also directed to my App with universalLinking, which I don't want, as it should be handled in the Browser. What am I missing? I was sure only /login/ should be directed to the app, and I don't seem to be able to prevent opening the app when navigating to other paths. I have tried returning NO within my continueUserActivity based on the userActivity.webpageURL without success. - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler I have also tried to add NOT * in the components array for the AASA file. Still the App will open when navigating to any path of my domain, regardless of the AASA Files components.
Replies
1
Boosts
0
Views
714
Activity
Nov ’21
NEHotspotConfigurationManager-Connect to captive Portal wifi
The wifi icon does not light up after the code is connected to public wifi. There is no way to keep the wifi connection down and lit up.
Replies
1
Boosts
0
Views
437
Activity
Oct ’21
New Objective-C project: what can't I do?
My next UIKit project will be in Objective-C. You can argue about why and such, but please know that there are idealist reasons for it. Having said that, what are the main things that aren't supported anymore in Objective-C (= only in Swift)? I don't mean language features, but mainly functional stuff like controls or services (eg. in-app purchases).
Replies
2
Boosts
0
Views
921
Activity
Oct ’21