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 ymlim_19.
Last updated
.
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 a.bogong.
Last updated
.
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
Posted Last updated
.
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 osos.
Last updated
.
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 Deodes.
Last updated
.
Post not yet marked as solved
1 Replies
410 Views
Hi, I want to understand the format of crash file generated by MacOs. is there any link or document that states the proper format of crash file.
Posted Last updated
.
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 kp008114.
Last updated
.
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 Last updated
.
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 Alain_B.
Last updated
.
Post not yet marked as solved
0 Replies
59 Views
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.
Posted
by Mayshock.
Last updated
.
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 nish_9493.
Last updated
.
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.
Last updated
.
Post not yet marked as solved
4 Replies
2.6k Views
On iOS 15 beta, when I tried to check my application, the select element is having issue. As when I clicked on select dropdown, the option list was not shown. The error message was "Failed to present a context menu for configuration with identifier".
Posted Last updated
.
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 Last updated
.
Post not yet marked as solved
2 Replies
379 Views
Hi everybody. I have an application written in Objective-C. Until recently, I continued to maintain it and write new features in Objective-C. It was decided to switch to Swift and implement all new features on Swift. As a result, I made a bridge between Objective-C and Swift. Added new classes in swift and imported them via bridge header. One of the tasks required adding functionality to an existing Objective-C class, but I decided to implement this by extending the Objective-C class in a swift file. Example Objective-C class Settings.h #import &lt;Foundation/Foundation.h&gt; @interface Settings : NSObject - (instancetype)initWithDictionary:(NSDictionary *)dictionary; - (BOOL)boolForKey:(NSString *)key; @end Settings.m #import "Settings.h" @implementation Settings {     NSDictionary *_dictionary; } - (instancetype)initWithDictionary:(NSDictionary *)dictionary {     self = [super init];     if (self) {         _dictionary = dictionary;     }     return self; } - (BOOL)boolForKey:(NSString *)key {     return [[_dictionary objectForKey:key] boolValue]; } @end Swift extension Settings+extension.swift import Foundation extension Settings {     @objc public func isFirstProperty() -&gt; Bool {         return self.bool(forKey: "isFirstProperty")     }     @objc public func isSecondProperty() -&gt; Bool {         return self.bool(forKey: "isSecondProperty")     } } Call example inside UICollectionViewController sub class @implementation CollectionViewController {     Settings* _settings; } -(void)viewDidLoad {     [super viewDidLoad]; _settings = [[Settings alloc] initWithDictionary:someDictionary]; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {     UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseIdentifier" forIndexPath:indexPath]; if ([_settings isFirstProperty]) { //Do something with cell according to firstProperty } else if ([_settings isSecondProperty]) { //Do something with cell according to secondProperty } return cell; } @end I tested the app, everything worked great. I uploaded the app to the App Store. Almost from the beginning of the use of the new application by users, I began to receive crash reports. Crash report Stack Trace I could not understand what was the matter. But after I removed the Swift extensions and implemented them directly in the Objective-C class, the crashes stopped. After removing Settings+extension.swift and implementing inside Settings.m/h Example Objective-C class Settings.h #import &lt;Foundation/Foundation.h&gt; @interface Settings : NSObject - (instancetype)initWithDictionary:(NSDictionary *)dictionary; - (BOOL)boolForKey:(NSString *)key; - (BOOL)isFirstProperty; - (BOOL)isSecondProperty; @end Settings.m #import "Settings.h" @implementation Settings {     NSDictionary *_dictionary; } - (instancetype)initWithDictionary:(NSDictionary *)dictionary {     self = [super init];     if (self) {         _dictionary = dictionary;     }     return self; } - (BOOL)isFirstProperty {     return [[_dictionary objectForKey:key] boolValue]; } - (BOOL)isSecondProperty {     return [[_dictionary objectForKey:key] boolValue]; } @end 1. Can somebody explain, why I had crashes? 2. Is it ok to extend Objective-C classes like that? 3. What kind of issues I can expect during migration to swift ?from Objective-C? (Any literature that explore this topic?) Thanks in advance!
Posted Last updated
.
Post not yet marked as solved
1 Replies
203 Views
DatePicker error is displayed when the locale supports RTL view. When I change the DatePicker style to inline style and change the default localization to ar (Arabic), the DatePicker shows number mirrors, after scrolling between months the display changes to the correct display but the day names are not associated with the day's numbers.
Posted
by Qoura.
Last updated
.