Objective-C

RSS for tag

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

Posts under Objective-C tag

222 Posts
Sort by:
Post not yet marked as solved
3 Replies
777 Views
Hi! I have a objc static lib with some depending framework files. I want to build a kind of wrapper to intercept some functions of the objc library. How can this be done? It's no problem to use the static lib and the framework files within a App-Target but I don't understand what to do to build a Swift static lib that uses this lib? Thanks!
Posted
by
Post not yet marked as solved
5 Replies
510 Views
I am running on macOS 13.3.1 (a). I have a longstanding macOS app with a document icon. I have changed app's icon and document icon in the latest release. The new application icon shows correctly on the app's icon, but the new document icon does not display properly in the title bar of my NSDocument windows. All I did was to change the application and document icons in the Asset catalog and recompile with Xcode 14.3. My documents are file packages. There are no copies of the application with the old document icon anywhere on my disk. If I create a new document using the app, the document displays the correct--new--icon, but when the app opens the document, the icon that appears in the title bar is the old document icon. When I discovered this I rebuilt the launch services database, but the problem remains. From where could the system be getting that old icon? Does anybody have any idea how to fix this?
Posted
by
Post not yet marked as solved
0 Replies
412 Views
Hello Guys! I want to use detent with custom size, we have a public API(customDetentWithIdentifier:resolver:) but is just for iOS 16+ and I want to use in iOS 15.0, If I use a private API like this #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface UISheetPresentationControllerDetent (Private) (UISheetPresentationControllerDetent *)_detentWithIdentifier:(NSString *)identifier constant:(CGFloat)constant; @end NS_ASSUME_NONNULL_END Then to use in Swift like this: let modalViewDente: UISheetPresentationController.Detent = ._detent(withIdentifier: "ModalViewDente", constant: 300.0) Can my app rejected by apple? If Yes why? Why are they not given to us a way to do also in iOS 15?
Post not yet marked as solved
2 Replies
1.8k Views
Hardware Model: iPhone12,8 Code Type: ARM-64 Parent Process: [1] Date/Time: 2023-05-14T09:24:05Z OS Version: iPhone OS 16.3.1 (20D67) Report Version: 104 Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0xd665cce30 Crashed Thread: 2 Thread 2 Crashed: 0 libobjc.A.dylib 0x00000001860db554 objc_release + 16 1 libsystem_blocks.dylib 0x00000001db1c9124 _call_dispose_helpers_excp + 48 2 libsystem_blocks.dylib 0x00000001db1c8d54 _Block_release + 248 3 libdispatch.dylib 0x000000019456cf88 _dispatch_client_callout + 16 4 libdispatch.dylib 0x0000000194574640 _dispatch_lane_serial_drain + 668 5 libdispatch.dylib 0x000000019457518c _dispatch_lane_invoke + 380 6 libdispatch.dylib 0x000000019457fe10 _dispatch_workloop_worker_thread + 648 7 libsystem_pthread.dylib 0x00000001db1ccdf8 _pthread_wqthread + 284 8 libsystem_pthread.dylib 0x00000001db1ccb98 start_wqthread + 4
Posted
by
Post not yet marked as solved
0 Replies
768 Views
I'm trying to find a more efficient way to generate the Apple-style /// code comments in Xcode. Although I can use Cmd + Option + Enter to automatically generate ///, it's not as convenient when copying(press option to select specific area) and pasting code. Is there a more streamlined approach to generate these comments, especially when pasting existing code? It's convenient to generate doc with old /** */
Posted
by
Post not yet marked as solved
0 Replies
393 Views
I'm trying to call Objective-C methods from SwiftUI. I have a bridging header with a number of imports from the SDK. Now, I'm trying get the ConenctSDK's devicePicker to display, but I'm stuck trying to get that to work. I'm coming back to Mac after a number of years and have just started using SwiftUI. With said, here is my code so far: import SwiftUI import ConnectSDK struct ContentView: View { class ConnectSDKHelper { func showDevicePicker () { let dm = DiscoveryManager.shared() dm?.startDiscovery() dm?.devicePicker() } } var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) } .padding() } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }' From googling, I determined that I need a 'help' class, ConnectSDKHelper. Not sure if it's correct, but if it is. I'm not sure how to apply it. All help appreciated.
Posted
by
Post not yet marked as solved
0 Replies
295 Views
I have two target in Swift package manager, one is Objective-C target and another one is Swift target. I have few Custom components in Objective-C target and need to access those components in Swift target. I have added Objective-C target as dependency to Swift target in package.swift. Still i am getting error on swift ViewController class showing "Cannot find type 'CustomTextView' in Scope". I need to access Objective-C custom components from Objective-C target to Swift target in local package.
Posted
by
Post not yet marked as solved
0 Replies
594 Views
Hi, I am using the below code to detect if NFC is enabled or not. (BOOL)isNFCAvailable { if ([NFCNDEFReaderSession readingAvailable]) { return YES; } return NO; } I have also added the permission is info.plist file NFCReaderUsageDescription Detecting if NFC is enabled or not I am testing on iphone XS with ios 15.6.1 and on iphone 11 with ios 13.2.2. In both the cases, the API is returning false. Can you please let me know if I am missing something.
Posted
by
Post not yet marked as solved
0 Replies
399 Views
Is there any way we can set a NSString from objC in UITextView by extending or without extending UITextView(without extending preferably). Reason -: My logic for action on text change will be triggered from cpp code .That is why i need to send the textview.text to objC on change of character .Is it possible to have a buffer of such type ? ,and if yes, is the memory delocation and allocation of buffer managed by xcode ? If any of the above thing is not possible ,then is there anyother way to achive similar behavior ? Any answer can help.
Posted
by
Post not yet marked as solved
0 Replies
435 Views
Can we directly get a refrence textview.text and use it as a objC's NSString .If yes ,do we need to handle memory dellocation or is it taken care by ARC? If we cann't directly take a refrence ,do we have another option than making a copy of textview.text and use it as a ObjC's NSString?
Posted
by
Post marked as solved
1 Replies
729 Views
Hi , I got this quote with 5800 repetitions (5.8 MB / 1k) : `2023-05-25 01:02:59.021733+0200 LookAt[6404:302136] [general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSNumber' (0x7ff84cfe02f8) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.objects', even though it was not explicitly included in the client allowed classes set: '{( "'NSMutableDictionary' (0x7ff84cfb6b48) [/System/Library/Frameworks/CoreFoundation.framework]", "'NSArray' (0x7ff84cfb68a0) [/System/Library/Frameworks/CoreFoundation.framework]" )}'. This will be disallowed in the future ` -(IBAction)readFile:(id)sender { NSData * data; NSError * error = nil; data = [_vrReadWrite readData:kFileComponentA]; NSSet * set = [_vrReadWrite setOfClasses]; _vrRoot = [NSKeyedUnarchiver unarchivedObjectOfClasses:set fromData:data error:&error]; }``` I got the expected result, that's fine, but I'm not interested in this future. Uwe
Posted
by
Post marked as solved
1 Replies
605 Views
Several years ago, I modified an [Apple Obj-c Time Zone] example (illustrated image below) to enrich my non-existent knowledge with Time Zones. The modified application illustrates the current [Time Zone Date and Time] for my current MDT location, and will illustrate another available [Time Zone Location] from a popup button. So, I decided to see whether I could convert the Obj-c code to Swift code. The converted Swift code built properly, but the application will repeatedly crash when I engage the Swift [clockAndCalendar binding]. The Swift code application generates the following error message: I understand the error message listed above to be: "EXC_BAD_ACCESS" error message (code=1, address=0x0) occurs when the application tries to access memory, which the application cannot access, or does not exist. Examining the error shows the MDT’s as the first encountered location: When I examine the additional [information] button, Xcode generates the following message, stating a [Foundation] incompatibility exists. Again, I wonder whether this issue can be resolved. So, for the moment, I believe I cannot produce an equivalent Swift file just yet without more knowledge, where I unwittingly, and most likely applied the Swift [clockAndCalendar binding] code incorrectly … ? I am curious about what I should do next, and how I might properly approach this error message ... ? NSTimeZone (Obj-c) and TimeZone (Swift) produce different [Time Zone] results, as noted in the associated [Print Statements]. Your possible suggestions for me to explore would be very welcome … :] Again, I must thank you for your time with this issue. Best regards, jim_k // The modified Obj-c View: // Obj-c [setupCityClock] code: - (void)setupCityClock:(NSView *)containerView timeZone:(NSTimeZone *)timeZone { NSDatePickerElementFlags flags = 0; flags |= NSDatePickerElementFlagHourMinute; flags |= NSDatePickerElementFlagHourMinuteSecond; flags |= NSDatePickerElementFlagTimeZone; flags |= NSDatePickerElementFlagYearMonth; flags |= NSDatePickerElementFlagYearMonthDay; flags |= NSDatePickerElementFlagEra; // Setup the city block and bind its value to a single NSDate property. NSDatePicker *theIdentifiedTimeZoneLocationCalendarAndClock = [[NSDatePicker alloc] initWithFrame:containerView.bounds]; // Draw the [Focus Ring] around the [Date Picker] theIdentifiedTimeZoneLocationCalendarAndClock.focusRingType = NO; // Draw the [datePicker Background colour] which makes the [background colour darker] theIdentifiedTimeZoneLocationCalendarAndClock.drawsBackground = YES; // Set the [datePicker Background Colour] to [TEXT BACKGROUND COLOUR] theIdentifiedTimeZoneLocationCalendarAndClock.backgroundColor = NSColor.blackColor; // Set the [datePicker Text Colour] to [WHITE] theIdentifiedTimeZoneLocationCalendarAndClock.textColor = NSColor.controlTextColor; // If the function is set to [YES] the [BORDER] is not [DRAWN] properly. // Setting the function to [NO] will not draw the [BORDER] theIdentifiedTimeZoneLocationCalendarAndClock.bordered = NO; // Set the [DATE PICKER STYLE] theIdentifiedTimeZoneLocationCalendarAndClock.datePickerStyle = NSDatePickerStyleClockAndCalendar; // Set the [DATE PICKER ELEMENTS] theIdentifiedTimeZoneLocationCalendarAndClock.datePickerElements = flags; // Set the [TIME ZONE] theIdentifiedTimeZoneLocationCalendarAndClock.timeZone = timeZone; // Check the results: NSLog(@"The [CURRENT TIME ZONE FOR (setupCityClock)] :: %@", timeZone); // Prints: - [America/Edmonton (MDT) offset -21600 (Daylight)] // Prints: - [Europe/London (GMT+1) offset 3600 (Daylight)] NSLog(@"The [CURRENT TIME ZONE FOR (setupCityClock) again] :: %@", theIdentifiedTimeZoneLocationCalendarAndClock.timeZone); // Prints: - [America/Edmonton (MDT) offset -21600 (Daylight)] // Prints: - [Europe/London (GMT+1) offset 3600 (Daylight)] // Bind the [TIME ZONES] to the [CURRENT TIME] [theIdentifiedTimeZoneLocationCalendarAndClock bind:NSValueBinding toObject:self withKeyPath:@"currentTime" options:nil]; // Add the [CITY CLOCK] to the [CONTAINER VIEW] [containerView addSubview:theIdentifiedTimeZoneLocationCalendarAndClock]; } // End of [- (void)setupCityClock:] // The modified Swift View [Without the [clockAndCalendar binding] engaged]: // NOTE: The clock’s static time differential is correct with each popup button selection. // Swift [setupCityClock] code: func setupCityClock(containerView: NSView, timeZone: TimeZone) { var flags = NSDatePicker.ElementFlags() flags.insert(.hourMinute) flags.insert(.hourMinuteSecond) flags.insert(.timeZone) flags.insert(.yearMonth) flags.insert(.yearMonthDay) flags.insert(.era) // Setup the city clock and bind its value to a single NSDate property. let theIdentifiedTimeZoneLocationCalendarAndClock = NSDatePicker(frame: containerView.bounds) // Draw the [Focus Ring] around the [Date Picker] theIdentifiedTimeZoneLocationCalendarAndClock.focusRingType = .none // Draw the [datePicker Background colour] which makes the [background colour darker] theIdentifiedTimeZoneLocationCalendarAndClock.drawsBackground = true // Set the [datePicker Background Colour] to [TEXT BACKGROUND COLOUR] theIdentifiedTimeZoneLocationCalendarAndClock.backgroundColor = NSColor.black // Set the [datePicker Text Colour] to [WHITE] theIdentifiedTimeZoneLocationCalendarAndClock.textColor = NSColor.controlTextColor // If the function is set to [YES] the [BORDER] is not [DRAWN] properly. // Setting the function to [NO] will [NOT] draw the [BORDER] theIdentifiedTimeZoneLocationCalendarAndClock.isBordered = false // Set the [DATE PICKER STYLE] theIdentifiedTimeZoneLocationCalendarAndClock.datePickerStyle = .clockAndCalendar // Set the [DATE PICKER ELEMENTS] theIdentifiedTimeZoneLocationCalendarAndClock.datePickerElements = flags // Set the [TIME ZONE] theIdentifiedTimeZoneLocationCalendarAndClock.timeZone = timeZone print("The [CURRENT TIME ZONE FOR (setupCityClock)] :: \(timeZone)") // Prints: - [America/Edmonton (fixed (equal to current))] // Prints: - [Europe/London (fixed)] // Bind the [TIME ZONES] to the [CURRENT TIME] <=== (The error occurs here) theIdentifiedTimeZoneLocationCalendarAndClock.bind(.value, to: self, withKeyPath: "currentTime", options: nil) // Add the [CITY CLOCK] to the [CONTAINER VIEW] containerView.addSubview(theIdentifiedTimeZoneLocationCalendarAndClock) } // End of [func setupCityClock(containerView: NSView, timeZone: TimeZone)]
Posted
by
Post not yet marked as solved
1 Replies
411 Views
I am trying to set Text value in my SwiftUI code from a char* string stored in cpp whenever a button is pressed .I was able to do similar think in UIkit based application and since i am new to SwiftUI not able to do same in SwiftUI. SwiftUI code : @state var title = "Title" var body: some View { Text(title) .bold() .font(.system(size: 40)) .frame(width: 250,height: 200,alignment: .center ) Button("Change title", action: ChangeTitle) } func ChangeTitle () { //change value of title } } Want to change the value of var title to char* str in cpp when button is pressed.
Posted
by
Post not yet marked as solved
0 Replies
517 Views
Hello, Metal is a hard biscuit. the first part of my project is to draw wired platonic solids, I replaced the triangle with a cube which I want to rotate with two sliders. But I don't no how, the MTKView is the view of the viewController, the sliders will rotate too, or not ? Would you developers use the XIP ?
Posted
by
Post not yet marked as solved
0 Replies
516 Views
I have a macOS app that has a lot of form type inputs throughout. As such I have subclassed NSPopUpButton and implemented canBecomeKeyView to return YES. This works great as users can tab through fields and pop up menus to enter data. The issue is that when tabbing to a pop up I expect the user to see instant changes as they type, instead it takes 1-2 seconds before the menu changes. If the user hits the down arrow key it expands the menu and then type selection is instantaneous. Is there any way to make NSPopUpButton respond instantly to typing, like a select menu in a web form? As it is it inhibits fast data input as you wait for it to recognize your input before tabbing to the next field.
Posted
by
Post not yet marked as solved
5 Replies
738 Views
I'm dynamically creating a UIImage from NSData using [UIImage imageWithData:data]. The call succeeds and returns a valid UIImage but every time I make the call CGImageCopyImageSource:4692: *** CGImageGetImageSource: cannot get CGImageSourceRef from CGImageRef (CGImageSourceRef was already released) is printed in the Console - not the Xcode console but the Console app streaming from the device. I haven't determined this is actually a problem but I have customer reports of my app crashing after a long period of time where this particular code path is being called frequently. If I put a symbolic breakpoint at ERROR_CGImageCopyImageSource_WAS_CALLED_WITH_INVALID_CGIMAGE is is hit. I'm not sure what I could be doing to cause this error since I'm passing valid data in and getting what looks like valid output.
Posted
by
Post not yet marked as solved
0 Replies
476 Views
I've got a macOS app that has a collection view all done with bindings and no datasource implementation. I've got it so I can drag and drop items, highlight selection and delete items. The last item is to bind the collection view selection to my array controller. In IB I select the collection view then in the bindings inspector I select the array controller under selection indexes and enter the controller key of selectionIndexes. But this does nothing. If I log the collection view selectionIndexes it shows correctly but the array controller will show nothing. I've fussed with this the entire day and am starting to believe it just won't work like it does with a table view. I thought about updating the array controller selection through the collection view delegate selection methods -didSelectItemsAtIndexPaths / didDeselectItemsAtIndexPaths but it feels like I must be missing something. Should this be possible and if not what are my alternatives?
Posted
by
Post not yet marked as solved
0 Replies
645 Views
Code file I am working in VOIP application. I can receive voip push when app in background or foreground. But when an app is killed and device locked voip delegate "didReceiveIncomingPushWithPayload" method not called. Also, I am facing below crash Killing VoIP app because it failed to post an incoming call in time VoIP push for app dropped on the floor
Posted
by
Post not yet marked as solved
7 Replies
1.1k Views
I HAVE BEEN GETTING THIS CRASH FOR 3 MONTHS NOW. I THINK I HAVE READ ALL FORUMS TO HELP ME FIND SOLUTION TO THIS, BUT TO NO AVAIL. PLEASE HELP! 0 libsystem_kernel.dylib 0x1f285b558 __pthread_kill + 8 1 libsystem_pthread.dylib 0x213529118 pthread_kill + 268 2 libsystem_c.dylib 0x1bb773c04 __abort + 128 3 libsystem_c.dylib 0x1bb71b184 abort + 192 4 libc++abi.dylib 0x213467bf8 abort_message + 132 5 libc++abi.dylib 0x213457444 demangling_terminate_handler() + 348 6 libobjc.A.dylib 0x1ad319ea4 _objc_terminate() + 144 7 libc++abi.dylib 0x213466fbc std::__terminate(void (*)()) + 16 8 libc++abi.dylib 0x213466f60 std::terminate() + 56 9 libdispatch.dylib 0x1bb6baec0 _dispatch_client_callout + 40 10 libdispatch.dylib 0x1bb6bdf8c _dispatch_queue_override_invoke + 788 11 libdispatch.dylib 0x1bb6cc944 _dispatch_root_queue_drain + 396 12 libdispatch.dylib 0x1bb6cd158 _dispatch_worker_thread2 + 164 13 libsystem_pthread.dylib 0x213522da0 _pthread_wqthread + 228 14 libsystem_pthread.dylib 0x213522b7c start_wqthread + 8
Posted
by