Objective-C

RSS for tag

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

Posts under Objective-C tag

304 Posts
Sort by:
Post not yet marked as solved
0 Replies
21 Views
I am seeking for this User Interface(UI) effect --> "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
Post not yet marked as solved
0 Replies
37 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
Post marked as solved
4 Replies
106 Views
Hi, I'm trying to lock a file from objective-c (or plain C) so that other processes cannot read or write to it. So far, unsuccessfully. I've tried to use all APIs I can think of, but none locked the file: open then flock open then lockf open with O_EXLOCK open then fcntl (F_SETLK) open then NSDistributedLock I'm running macOS 11.6.1 on an APFS drive. For every API used, I was able to open and edit the file from command line using vi or just using cat on the file. Isn't there any way of preventing another process from accessing a file, until I'm done with it (ie. I closed the file, or the file handle is relinquished)? Thanks, Chris
Post not yet marked as solved
0 Replies
87 Views
I built a MacOs app, and it works fine, but the problem happens when I achieve the project. When I tried from an old Xcode version (12.3) Macbook Pro late 13 it works But when I run from Macbook pro-2020 (M1 chip), the issue happened while archiving, and works fine while running, I use Xcode 14 beta. The app is written in objective-c I get this error: /Users/usamafouad/Downloads/Oil Paint - Mac/Oil Paint App/frameworks/Source/Mac/GPUImageMac-Prefix.pch error build: Build input file cannot be found: '/Users/usamafouad/Library/Developer/Xcode/DerivedData/Oil_Paint-dywawlmfpsulhqapvsuiigxhgkrs/Build/Intermediates.noindex/ArchiveIntermediates/Oil Paint/InstallationBuildProductsLocation/@loader_path/../Frameworks/GPUImage.framework/Versions/A/Modules/module.modulemap' Could you please help me, it's an urgent issue?
Posted
by
Post not yet marked as solved
0 Replies
94 Views
I have a project in react-native and I'm using react-native-video library for providing videos in my app. I have many videos components within app, but they must have different AVAudioSession category and options. But when I first time set category and options to AVAudioSession, then it applies to every video entity in my app.. The code for configuring audio is below: - (void)configureAudio { AVAudioSession *session = [AVAudioSession sharedInstance]; AVAudioSessionCategory category = nil; AVAudioSessionCategoryOptions options = nil; if([_ignoreSilentSwitch isEqualToString:@"ignore"]) { category = AVAudioSessionCategoryPlayback; } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { category = AVAudioSessionCategoryAmbient; } if([_mixWithOthers isEqualToString:@"mix"]) { options = AVAudioSessionCategoryOptionMixWithOthers; } else if([_mixWithOthers isEqualToString:@"duck"]) { options = AVAudioSessionCategoryOptionDuckOthers; } if (category != nil && options != nil) { [session setCategory:category withOptions:options error:nil]; } else if (category != nil && options == nil) { [session setCategory:category error:nil]; } else if (category == nil && options != nil) { [session setCategory:session.category withOptions:options error:nil]; } } The code where I call this method: - (void)setIgnoreSilentSwitch:(NSString *)ignoreSilentSwitch { _ignoreSilentSwitch = ignoreSilentSwitch; [self configureAudio]; [self applyModifiers]; } - (void)setPaused:(BOOL)paused { if (paused) { [_player pause]; [_player setRate:0.0]; } else { [self configureAudio]; if (@available(iOS 10.0, *) && !_automaticallyWaitsToMinimizeStalling) { [_player playImmediatelyAtRate:_rate]; } else { [_player play]; [_player setRate:_rate]; } [_player setRate:_rate]; } _paused = paused; } Config must change every time when user call setIgnoreSilentSwitch('some value') or setPaused(false), but it doesn't happen..
Posted
by
Post not yet marked as solved
0 Replies
70 Views
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?
Posted
by
Post not yet marked as solved
0 Replies
80 Views
Hello, I'm trying to write a simple program which should be able to set wireless profiles. I'm using commitConfiguration function of CWInterface (https://developer.apple.com/documentation/corewlan/cwinterface/1426430-commitconfiguration?language=objc) in order to set the profile and then call CWKeychainSetWiFiPassword to set the corresponding password. However when I try to save the profile using commmitConfiguration, the function returns FALSE and the NSLog of error returns null. The program I'm writing must use wxWidgets library so it's compiled outside Xcode and it's also coded on both C++ and Objective C. I'm currently using CMake to automate the build process. Here there is the snippet of code: NSArray<CWInterface*>* interfaces = wifiClient.interfaces; for(int i = 0; i < interfaces.count; i++){ NSError* configError = nil; CWMutableConfiguration* configCopy = [[CWMutableConfiguration alloc] initWithConfiguration:interfaces[i].configuration]; NSOrderedSet<CWNetworkProfile *>* networkProfiles = configCopy.networkProfiles; NSMutableOrderedSet<CWNetworkProfile*> *networkProfilesCopy = networkProfiles.mutableCopy; CWMutableNetworkProfile* networkProfile = [[CWMutableNetworkProfile alloc] init]; NSString* name = [[NSString alloc] initWithBytes: name length: strlen(name) encoding: NSUTF8StringEncoding]; NSString* password = [[NSString alloc] initWithBytes: password length: strlen(password) encoding: NSUTF8StringEncoding]; NSInteger networkProfileIndex; OSStatus keychainStatus; bool configStatus; //... fragment of code which sets the security algorithm for the network omitted... networkProfile.ssidData = [name dataUsingEncoding:NSUTF8StringEncoding]; networkProfileIndex = [networkProfilesCopy indexOfObject:networkProfile]; //If network profile already exist, replace it without changing its position in the ordered set if(networkProfileIndex == NSNotFound){ [networkProfilesCopy addObject:networkProfile]; }else{ [networkProfilesCopy replaceObjectAtIndex:networkProfileIndex withObject:networkProfile]; } [configCopy setNetworkProfiles:networkProfilesCopy]; configStatus = [interfaces[i] commitConfiguration:configCopy authorization:nil error:&configError]; if(configStatus){ keychainStatus = CWKeychainSetWiFiPassword(kCWKeychainDomainUser, networkProfile.ssidData, password); return keychainStatus; }else{ NSLog(@" error => %@ ", [configError userInfo]); return false; } } The strange thing I noticed is that if I run the program using sudo, commitConfiguration seems to work. Thanks in advance
Posted
by
Post not yet marked as solved
0 Replies
92 Views
In the "mouseDown" (or MouseDreagged) code below Enclosure is a NSView subclass. xcode report 2 warnings: pb_item setDataProvider:self forTypes:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, NSPasteboardTypePDF, @"LN_PboardType", nil]]; Sending 'Enclosure *' to parameter of incompatible type 'id _Nonnull' NSDraggingSession *draggingSession = [self beginDraggingSessionWithItems:[NSArray arrayWithObject:drag_item] event:drag_event source:self]; Sending 'Enclosure *' to parameter of incompatible type 'id _Nonnull' The application fail at: drag_item = [[NSDraggingItem alloc] initWithPasteboardWriter:pb_item]; Pasteboard item data provider <Enclosure: 0x7f849ec74e70> must conform to NSPasteboardItemDataProviderProtocol [General] There are 0 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem. However if in the line of code above "pb_item" is replaced by "drag_image" drag work fine (but without drop). The z_drag image follow the mouse correctly and "endedAtPoint" is called when the mouse button is released. Where is the error ? Any suggestion will be appreciate... BigSur, xcode 12.4 - (void)mouseDown:(NSEvent *)drag_event /* or mouseDragged:(NSEvent *)drag_event */ { NSImage *drag_image; NSPoint drag_position; NSDraggingItem *drag_item; NSPasteboardItem *pb_item; pb_item = [[NSPasteboardItem alloc] init]; [pb_item setDataProvider:self forTypes:[NSArray arrayWithObjects:NSPasteboardTypeTIFF, NSPasteboardTypePDF, @"LN_PboardType", nil]]; drag_image = [NSImage imageNamed:@"z_drag.jpg"]; drag_item = [[NSDraggingItem alloc] initWithPasteboardWriter:pb_item]; drag_position = [self convertPoint:[drag_event locationInWindow] fromView:nil]; drag_position.x -= [drag_image size].width/2; drag_position.y -= [drag_image size].height/2; [drag_item setDraggingFrame:NSMakeRect(drag_position.x, drag_position.y, drag_image.size.width, drag_image.size.height) contents:drag_image]; NSDraggingSession *draggingSession = [self beginDraggingSessionWithItems:[NSArray arrayWithObject:drag_item] event:drag_event source:self]; [draggingSession setAnimatesToStartingPositionsOnCancelOrFail:YES]; [draggingSession setDraggingFormation:NSDraggingFormationNone]; } - (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { switch (context) { case NSDraggingContextWithinApplication: return NSDragOperationCopy; case NSDraggingContextOutsideApplication: return NSDragOperationMove; } return NSDragOperationNone; } - (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation { NSPoint mouse_point; mouse_point = [session draggingLocation]; switch (operation) { case NSDragOperationDelete: break; default: break; } }
Posted
by
Post not yet marked as solved
0 Replies
87 Views
Hi everybody! Please help to overcome the error during app compilation SVProgressHUD/SVProgressHUD.h' file not found The app was created in xCode 11 and migrated from old Mac to the new one on M1, cache files cleaned, arm64 preselected in build settings, pods reinstalled many times, build folder cleaned, cocoapods updated and i checked every solution i found on the Internet. Nothing helped. Please share your suggestions if you faced the same error and could get rid of it. Thank you for every piece of advice!
Posted
by
Exe
Post not yet marked as solved
1 Replies
132 Views
Hi I have an objective project and when I'm extending the project to Swift It works fine when locally testing it and also when testing it over testflight. But after submitting the app to the appstore and when users download it and use I see crash reports coming from the Sentry related with the swift extensions created over the objective-c class. I'm unable to reproduce this locally. Any Help would be appreciated. Attached the crash report. 605534285f8e4c96af32cf25bb283439-symbolicated.crash
Posted
by
Post not yet marked as solved
1 Replies
75 Views
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.
Posted
by
Post not yet marked as solved
0 Replies
119 Views
Rosetta 2 is not installed by default, you are prompted to install it for the first run of an x64 app - but only in the gui. If you run an x64 app from the command line, directly or prefixed with arch -arch x86_64, it will simply fail. You have to double-click an x64 .app bundle in the Finder to trigger the "Would you like to install Rosetta?" popup. Is there any way/API available to launch intel app/binary via terminal/NStask so that OS can show popup instead of launch failing. If not, any cmd available to show rosetta pop?
Posted
by
Post not yet marked as solved
0 Replies
130 Views
I'm having trouble with memory leaks. I want to get shader's reflection data from MTLFunction which is generated from precompiled shader files. These files are compiled with Metal Developer Tools for Windows 2.3 and I use the following command options. -x metal hoge.metal -std=ios-metal2.0 -o hoges.msl To get these reflection data, I use the function newArgumentEncoderWithBufferIndex:reflection:. I can get the reflection data, but some memory leaks occur for each call this function, and I don't know how to release the memory of the reflection data. This is a example code. void Func(id<MTLFunction> _pShaderFunc) { MTLAutoreleasedArgument reflection = nil; id<MTLArgumentEncoder> argEnc = [_pShaderFunc newArgumentEncoderWithBufferIndex:0 reflection:&reflection]; // some process... // [reflection release]; // run-time error. [argEnc release]; } I tested this on iPhone 11 Pro Max with iOS 13.3.1, Xcode 13.1, and Mac mini(2018) with macOS Monterey 12.4. I compiled source files specifying the option -fno-objc-arc. I used the instrument Leaks, and I confirmed when this function isn't called, there were no memory leaks. Could you give me some advice on how to resolve those leaks?
Posted
by
Post not yet marked as solved
0 Replies
72 Views
Hi all, I have an application which is getting a segmentation fault when releasing an autorelease pool, but weirdly, it seems to be happening only on earlier OS versions. I and another person have tested it on Monterey and it works, but a tester has High Sierra and it's crashing. I have tested it on my system for zombies, with address sanitizer turned on, everything I can think of, and no issues. This is part of the the stack trace: Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x000070ff5dfdbec0 Exception Note: EXC_CORPSE_NOTIFY Application Specific Information: objc_msgSend() selector name: release 0 Crashed:: Dispatch queue: com.apple.main-thread libobjc.A.dylib 0x00007fff5ef99e9d objc_msgSend + 29 1 com.apple.Foundation 0x00007fff3a2f0c01 NSKVODeallocate +192 2 libobjc.A.dylib 0x00007fff5ef9d042 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 812 3 com.apple.AppKit 0x00007fff35f25f24 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4028 4 com.apple.AppKit 0x00007fff35784d6d -[NSApplication run] + 764 5 com.apple.AppKit 0x00007fff35753f1a NSApplicationMain + 804 6 libdyld.dylib 0x00007fff5fb94115 start + 1 I am at a bit of a loss as to how to debug this, since nothing is turning up on my system, and it seems to be occurring only on an older version of the OS where I can't debug it. Any clues or ideas for how to track it down would be most welcome.
Posted
by
Post not yet marked as solved
0 Replies
109 Views
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.
Posted
by