Objective-C

RSS for tag

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

Posts under Objective-C tag

212 Posts
Sort by:
Post marked as solved
1 Replies
753 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
619 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
419 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
532 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
524 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
756 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
482 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
652 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.2k 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
Post not yet marked as solved
0 Replies
454 Views
Hi, Im using the CNContactStore.currentHistory (available from iOS 13) to get token and check version of contacts. Everything is good til I try it on iOS 13 and iOS 14. Token is always nil from both ObjC and Swift. Is it a bug? Or have any way to handle that instead? Have any way to get token in iOS 13, 14? Any help would be greatly appreciated. Thank you!
Posted
by
Post not yet marked as solved
0 Replies
642 Views
I've got some old Objective-C code that up until Xcode 15 was compiling just fine. I recently spent time converting a lot of my project to Swift, which meant putting more stuff in the Bridging Header, but everything was fine. Till today. In file included from /Users/rmann/Projects/Personal/MyApp/repo/src/objc/MissionList/EventListCell.mm:18: In file included from /Users/rmann/Library/Developer/Xcode/DerivedData/MyApp-hkqhwvmmxqyxlkdlbpsbletzgerr/Build/Intermediates.noindex/MyApp.build/Debug-iphonesimulator/MyApp.build/DerivedSources/MyApp-Swift.h:288: In file included from /Users/rmann/Projects/Personal/MyApp/repo/src/BridgingHeader.h:8: /Users/rmann/Projects/Personal/MyApp/repo/src/objc/HessianClasses/CWHessianArchiver.h:52:55: error: reference to 'Protocol' is ambiguous +(void)setClassName:(NSString*)className forProtocol:(Protocol*)aProtocol; ^ note: candidate found by name lookup is 'Protocol' note: candidate found by name lookup is 'Protocol' This is code that uses NSProxy and passes it an Objective-C protocol. The build transcript does not show the locations of the alleged declarations. If I use Shift-Command-O and type "Protocol", I get /Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/objc/Protocol.h, which is unexpected, given that I'm running Xcode 15 beta 2. xcode-select -p gives /Applications/Xcode-beta.app/Contents/Developer. I call this a bug, as it compiles fine in Xcode 14.3, and if it should be an error, it should say why it's ambiguous. FB12434640
Posted
by
Post not yet marked as solved
0 Replies
656 Views
Hello! I have a static lib project in Objective-C, in the project I have set... Build Documentation During 'Build' -> Yes Build Multi-Language Documentation for Objective-C ony Targets -> Yes The documentation viewer opens after that, but the target is not present under Objective-C?
Posted
by
Post not yet marked as solved
1 Replies
1k Views
I am trying to learn how PAM works in macOS, in that process I came across one of the apple open source project in git hub. So I downloaded the project and opened it in xcode. When I tried to build the project initially I got base SDK error. I resolved that by changing the value to macOS(initially the value for base SDK is macosx.internal). After that most of the dependency error are resolved but now I am getting some of the header files are not found and also some of '.a' files are also missing. I have explored over the internet for those files but unable to get those. I have attached the missing header files and '.a' files below. Can you please help me in build this project. GitHub link: [https://github.com/apple-oss-distributions/pam_modules/tree/pam_modules-195) Header files: #include <Security/SecKeychainPriv.h> #include <OpenDirectory/OpenDirectoryPriv.h> #include <Heimdal/krb5.h>
Posted
by
Post not yet marked as solved
2 Replies
515 Views
Hello, There is a problem when querying flag state using the following API CGEventSourceFlagsState(kCGEventSourceStateHIDSystemState). When there is external mouse movement the flag gets reset by a low OS-level event corresponding to mouse move. As a result the modifier keys don’t work as expected when using Java’s Robot which in-turn uses Apple's native CGEvent APIs. The issue occurs at CRobot.m#L295 the flags gets reset or cleared when mouse is moved physically in unison with Robot's key events. The difference can be seen in the logs without and with mouse move for typing 'A'. (log attached) Logs Due to this issue applications that use Java's Robot on Mac don’t work as expected, in particular this behavior breaks the usability of the on-screen accessibility related keyboard application - TouchBoard. More details of this use case here. https://github.com/adoptium/adoptium-support/issues/710 The Robot is initialized with the following initial configurations - https://github.com/openjdk/jdk/blob/ac6af6a64099c182e982a0a718bc1b780cef616e/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m#L125 Are we missing anything during initialization of Robot which cause this issue? Why does an external mouse movement cause the event flags to reset? Since a low level OS event corresponding to mouse move is causing the flag to reset, there might be an issue within the CGEventSourceFlagsState() API. Is there a reason behind why an external mouse event causes CGEventFlag state to reset to 0 ? Is there any known issue regarding CGEventSourceFlagsState() and a workaround for it?
Posted
by
Post marked as solved
1 Replies
965 Views
I have a MacOS project with several targets and in which I have been refactoring Obj-C classes over to Swift 1 by 1. I have been doing this for months and all was fine and building well until the most recent class. But with that one the project simply refuses to build. I see the ProjectName-Swift.h file in the Project folder but the last build date was over a week ago and so it obviously does not include the new class, hence Xcode is complaining it can't find the new Swift Class. Understand the following before answering please: This is a very old and longstanding MacOS project with several targets, it is NOT a new MacOS project. I have previously added quite a few other Swift classes (using Swift 5) to this project and was able to build and run just fine. I have tried clean and build about 50 times and removing derived data. Nothing will force a rebuild of the ProjectName-Swift.h and the new class is definitely NOT in there. There are no other build issues with this project, just the one related to not being able to see the new class. The class was previously implemented in Obj-C and I was porting it over and that old class file is not referenced by the project at the moment. This Swift class ChartListTableCellView is NOT referenced in the obj.h file so it is not forward referenced there. The Bridge Header is imported in the .m that is complaining. Because Xcode is not seeing the Swift Class in the ProjectName-Swift.h it will not build and I am sort of in a chicken and egg circle jerk here. I even tried using the old Header at the top of the .m file where I need this class and it gets further but not far enough to build the Bridge Header. This is how the new class is declared so it should be visible. @objcMembers class ChartListTableCellView : NSView { private let grayBottomBorder = NSView() ... init() { super.init(frame: NSMakeRect(0, 0, 0, 0)) ... } ... } I am stumped and am out of ideas. Apple!! Seriously there needs to be a simple way to force a rebuild of the ProjectName-Swift.h file.
Posted
by
Post not yet marked as solved
0 Replies
914 Views
i have this issue with flutter project Parse Issue (Xcode): Could not build module 'GoogleSignIn' and i can't run my project any help please xcode 13 Launching lib/main.dart on myphone's iPhone in debug mode... Automatically signing iOS for device deployment using specified development team in Xcode project: PK582D5UEM Running Xcode build... Xcode build done. 132.2s Failed to build iOS app Could not build the precompiled application for the device. Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'GoogleSignIn.GIDAuthentication': '/Users/dev.user/Desktop/Project/cbody/ios/Pods/Headers/Public/GTMAppAuth/GTMAppAuthFetcherAuthorization.h' /Users/dev.user/Desktop/Project/cbody/ios/Pods/GoogleSignIn/GoogleSignIn/Sources/Public/GoogleSignIn/GIDAuthentication.h:23:8 Parse Issue (Xcode): Could not build module 'GoogleSignIn' /Users/dev.user/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.6.2/ios/Classes/FLTGoogleSignInPlugin.m:7:8 Error launching application on myphone’s iPhone.
Posted
by