Objective-C

RSS for tag

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

Posts under Objective-C tag

300 Posts
Sort by:
Post not yet marked as solved
1 Replies
40 Views
We are developing a document-based Objective-C project, using NSPersistentDocument and NSPersistentStore to save a unique binary file on disk. No autosave. Our application sometimes throws NSFileWriteUnknownError when trying to save the document, but the error description is obviously vague as this is an "unknown" error, not allowing us to debug easily. Why would such an unknown error be ever raised? Why doesn't Core Data know why it cannot save a file? We build using SDK 10.14 and run on macOS Monterey 12.3.1
Posted Last updated
.
Post not yet marked as solved
1 Replies
45 Views
We are a CEF based application, we utilize "Kiosk" mode by using the API enterFullScreenMode withoptions to enter kiosk mode. On Ventura beta release, when we exit this mode using [self.mContentView exitFullScreenModeWithOptions:[NSDictionary dictionary]]; None of the mouse controls work, we don't get hover states and clicking on buttons do not work.
Posted
by whatthef.
Last updated
.
Post not yet marked as solved
0 Replies
58 Views
The manufacturer data from a peripheral seems to be getting an extra byte... My peripheral is sending these bytes: 0x0c 0xff 0xe5 0x02 0x00 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 The 0c means there are 12 more bytes coming. The ff means it's a manufacturer message. The next 2 bytes are the manufacturer id. The next 9 bytes are the custom manufacturer data. Here's what I'm getting from CBCentralManager.didDiscoverPeripheral: advertisementData: { kCBAdvDataIsConnectable = 1; kCBAdvDataLocalName = "SQ-SPT-0021 432190009"; kCBAdvDataManufacturerData = {length = 12, bytes = 0xe50200000101000000000000}; kCBAdvDataRxPrimaryPHY = 0; kCBAdvDataRxSecondaryPHY = 0; kCBAdvDataServiceUUIDs = ( "00000100-34ED-12EF-63F4-317792041D17" ); kCBAdvDataTimestamp = "681852653.472335"; } ... here's what I would expect in the 'kCBAdvDataManufacturerData' vs. what I'm getting: 0x00 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 I lined these up to hopefully show that there's an extra 0x00 byte at the beginning (this is clearer with more non-zero bytes, but I didn't want to make up data, and I don't have the old data available). Where is this extra byte coming from, and how can I get rid of it? Changing the peripheral data is a possibility here.
Posted
by sqsabbey.
Last updated
.
Post not yet marked as solved
4 Replies
118 Views
Hi All, We are trying to build demo tool by using Network framework API. Here is the code in Objective-c: // //  main.m // #import <Foundation/Foundation.h> #import <Network/Network.h> char *hostname = ""; char *port = ""; nw_connection_t serverConnection; void stopConn() {    nw_connection_cancel(serverConnection); } void connectionDidEnd(NSError *error) {     NSLog(@"connectionDidEnd: %@", [error localizedDescription]);     stopConn(); } void connectionDidFail(NSError *error) {     NSLog(@"connectionDidFail: %@", [error localizedDescription]);     stopConn(); } void connectionReady(nw_connection_t connection) {     NSString *data = @"somedata";     NSData *rawData = [data dataUsingEncoding:NSUTF8StringEncoding];     nw_connection_send(connection, (dispatch_data_t _Nonnull)rawData, NW_CONNECTION_DEFAULT_MESSAGE_CONTEXT, FALSE, ^(nw_error_t  _Nullable error)     {         if (error != NULL)         {             NSLog(@"connection did send Failed.");             connectionDidFail((NSError*)error);             return;         }             NSLog(@"connection did send, data: %@",[[NSString alloc] initWithData:rawData encoding:NSUTF8StringEncoding]);     }); } void setupReceive(nw_connection_t connection) {     nw_connection_receive(connection, 1, 65536, ^(dispatch_data_t  _Nullable content, nw_content_context_t  _Nullable context, bool is_complete, nw_error_t  _Nullable error) {         nw_retain(context);         if (content != NULL)         {             NSString *data = [[NSString alloc] initWithData:(NSData*)content encoding:NSUTF8StringEncoding];             NSLog(@"setupReceive: Receive Data = %@",data);         }         if (is_complete) {             connectionDidEnd((NSError*)error);         } else if (error != NULL) {             connectionDidFail((NSError*)error);         } else {             setupReceive(connection);         }     }); } int main(int argc, const char * argv[]) {     @autoreleasepool {         nw_endpoint_t endpoint = nw_endpoint_create_host(hostname, port);         serverConnection = nw_connection_create(endpoint, nw_parameters_create_secure_tcp(NW_PARAMETERS_DEFAULT_CONFIGURATION, NW_PARAMETERS_DEFAULT_CONFIGURATION));         nw_retain(serverConnection);         nw_connection_set_queue(serverConnection, dispatch_get_main_queue());           nw_connection_set_state_changed_handler(serverConnection, ^(nw_connection_state_t state, nw_error_t  _Nullable error) {             switch (state) {                 case nw_connection_state_invalid:                     NSLog(@"Invalid");                     break;                 case nw_connection_state_waiting:                     NSLog(@"waiting");                     break;                 case nw_connection_state_preparing:                     NSLog(@"Preparing");                     break;                 case nw_connection_state_ready:                     NSLog(@"Client connection ready");                     connectionReady(serverConnection);                     break;                 case nw_connection_state_failed:                     NSLog(@"FAILED...");                     connectionDidFail((NSError*)error);                     break;                 case nw_connection_state_cancelled:                     connectionDidEnd((NSError*)error);                     NSLog(@"connection cancelled");                     break;                 default:                     NSLog(@"Unknown State = %d",state);                     break;             }         });         setupReceive(serverConnection);         nw_connection_start(serverConnection);         dispatch_main();     }     return 0; } Above code is not able to send command to server and always we receive below error nw_protocol_boringssl_write_frames_block_invoke(892) [C1:1][0x1040682a0] Failed to allocate buffer for external data Please let us know if we are doing anything wrong here. Thanks & Regards, Mohmad Vasim
Posted Last updated
.
Post marked as solved
5 Replies
12k Views
I had many swift compiler errors of this type : "Cannot find type 'className' in scope" after passing from Xcode 12.5 to Xcode 13. And the error is always referred to Objective-C classes. The project is for an iOS 11 app for iPad. The bridging-header is correctly set and the project with the same build-settings has never given this error before Xcode 13. I'll try to clean the derived data folder without success. the strange thing is project compile successfully and I can run on simulator as well but after few second from a successful compilation on any swift files that use objective-c class is fired the swift compiler error. Any idea? thanks
Posted
by mrcdev.
Last updated
.
Post not yet marked as solved
3 Replies
215 Views
webView.scrollView.bounces = NO; I set up the code, but the webView can still slide up and down. I assigned a color to the scrollView, I'm sure that's not the scrolling effect of the web page. I am using WKWebview. While the property bounces cannot control the display of the extra area, the property alwaysBounceVertical can. Sorry, I can't take a screenshot. Will this issue be fixed after the official version is released? Or that it was expected. My Xcode: Version 14.0 beta 4 (14A5284g) Simulator: iPhone 13 Pro - iOS 16.0
Posted Last updated
.
Post marked as solved
3 Replies
95 Views
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?
Posted
by monotone.
Last updated
.
Post not yet marked as solved
1 Replies
473 Views
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
Posted
by Roucoz.
Last updated
.
Post not yet marked as solved
1 Replies
86 Views
If I remember correctly, back in the days Xcode used to generate the main function something like this (at least for iOS applications): int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]); } } I.e. UIApplicationMain function was wrapped inside of @autoreleasepool. However I noticed that currently Xcode no longer does that: int main(int argc, char * argv[]) { NSString * appDelegateClassName; @autoreleasepool { // Setup code that might create autoreleased objects goes here. appDelegateClassName = NSStringFromClass([AppDelegate class]); } return UIApplicationMain(argc, argv, nil, appDelegateClassName); } So, UIApplicationMain is outside of the autorelease pool by default nowadays. Is there any official changelog/paper that explains why the latter implementation is now preferred over the former one?
Posted Last updated
.
Post not yet marked as solved
1 Replies
87 Views
Using NSDocument.readFromData and NSKeyedUnarchiver.unarchiveObjectWithData, I retrieve an object (of type A) with a property of type NSMutableArray. That array contains a nested chain of objects of type A. The problem object is a child of a child... in that array. I try to do Count on that array and I get an error.
Posted Last updated
.
Post not yet marked as solved
1 Replies
64 Views
Hello all! Need to get access to the parameters of main function from application delegate method "willFinishLaunchingWithOptions". How it could be? Fond in ProcessInfo this functionality: NSArray* oArguments = [[NSProcessInfo processInfo] arguments]; But how to get original int argc and const char* argv[]? Or how to convert NSArray* to const char* argv[]?
Posted
by a.bogong.
Last updated
.
Post not yet marked as solved
6 Replies
3.5k Views
Hello everyone, Is there a way to make an application widget like button appears all the time, even on the home screen. I want to make a floating button which will appear on top of all the apps. I want to build an application similar to assistive which will appear on home screen and on top of other apps.
Posted Last updated
.
Post not yet marked as solved
1 Replies
78 Views
Hello all! Is there any way to get launchOptions at runtime? When application already launched and working. It means not in the methods "willFinishLaunchingWithOptions" and "didFinishLaunchingWithOptions". Is this launchOptions, that passed into this application delegate methods, stored somewhere else? If yes - how to get them? My application is written on C++ and need to get independently when application is already running.
Posted
by a.bogong.
Last updated
.
Post not yet marked as solved
0 Replies
144 Views
I am seeking for this User Interface(UI) effect --&gt; "Spotlight" a specific IBOutlet (Please see attached Image2.png below) for a week! Explain the "Spotlight" effect : I wish to create is effect similar to NSAlert or beginSheet effect which user cannot click or access the entire window/view until user trigger a button and it back to normal. The whole window/view will becoming darken or gray EXCEPT a specific button I allow my user to interact with. Yet, I found that there is no any trick to create such effect neither in XIB file nor objective-c code. This is urgent for me. Eagerly waiting for your reply. Much Appreciated. (Image 1.png) (Image 2.png)
Posted
by ymlim_19.
Last updated
.
Post not yet marked as solved
0 Replies
113 Views
Hello all! Right now developing application that should be starting by crossing geofence. Right now have strange problem. The application launching when some other application keeping CoreLocation active and gathering data on iOS 15, on iOS 13 all is working with delay, but working. The geofenge regions started for monitoring, there are presented icon on top bar. What is missed by me in this case? Is there working example?
Posted
by a.bogong.
Last updated
.