Objective-C

RSS for tag

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

Posts under Objective-C tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Swift / Objective C interoperability
I am working on an app in Objective C. I added the the StoreKit framework with the logic using swift. everything worked as planned except for when I wanted to access properties and methods from my ObjC ViewController in the swift code. I did everything as is directed in the apple developer documentation, except it didn't work. I kept receiving the following errors; failed to emit precompiled bridging header ViewController.h file not found ( for the import code in the bridging header) I spent a whole day perusing the internet for a solution. Unfortunately, nothing worked. I thought I should try to import other classes from the ObjC into the bridging header. When I imported 3 files the 3rd one took after commenting out the 2 above it. Then I imported the ViewController again and the build was successful. I deleted every imported file above the file that I need to make visible to the swift compiler leaving the empty lines above it. Apparently, I was getting the errors because my import code was on line 4 instead of line 9, although the file is completely empty except for the comments created by Xcode when the file was automatically created. I am not sure why the placement of the line of code holds that much weight when the file is empty? **Can anyone explain to me any technicality that would lead to this issue? **
1
0
532
Feb ’24
Duplicate symbol error but Xcode doesn't specify where
I have an Xcode project that include a .c file and .h header file. I am getting a duplicate symbol error and I cannot pinpoint what part of my code is the issue or maybe if it's a configuration issue in my Xcode settings or not. Here's my .h header file code with my declarations: #define smc_h #include <stdint.h> #include <mach/mach.h> #include <IOKit/IOKitLib.h> typedef struct { uint32_t datasize; uint32_t datatype; uint8_t data[8]; } SMCVal_t; extern io_connect_t conn; kern_return_t openSMC(void); kern_return_t closeSMC(void); kern_return_t readSMC(char *key, SMCVal_t *val); double convertToFahrenheit(SMCVal_t *val); #endif /* smc_h */ And here is my .c implementation: #include "smc.h" #include <mach/mach.h> #include <IOKit/IOKitLib.h> io_connect_t conn; kern_return_t openSMC(void) { kern_return_t result; kern_return_t service; io_iterator_t iterator; service = IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("AppleSMC"), &iterator); if(service == 0) { printf("error: could not match dictionary"); return 0; } result = IOServiceOpen(service, mach_task_self(), 0, &conn); IOObjectRelease(service); return 0; } kern_return_t closeSMC(void) { return IOServiceClose(conn); } kern_return_t readSMC(char *key, SMCVal_t *val) { kern_return_t result; uint32_t keyCode = *(uint32_t *)key; SMCVal_t inputStruct; SMCVal_t outputStruct; inputStruct.datasize = sizeof(SMCVal_t); inputStruct.datatype = 'I' << 24; //a left shift operation. turning the I into an int by shifting the ASCII value 24 bits to the left inputStruct.data[0] = keyCode; result = IOConnectCallStructMethod(conn, 5, &inputStruct, sizeof(SMCVal_t), &outputStruct, (size_t*)&inputStruct.datasize); if (result == kIOReturnSuccess) { if (val -> datasize > 0) { if (val -> datatype == ('f' << 24 | 'l' << 16 | 't' << 8 )) { //bit shifting to from 32bit operation associated with the ASCII charecters'f', 'l', and 't', sets datatype field. double temp = *(double *)val -> data; return temp; } } } return 0.0; } double convertToFahrenheit(SMCVal_t *val) { if(val -> datatype == ('f' << 24 | 'l' << 16 | 't' << 8 )) { //checking if val->datatype is equal to the result of the bit-shifting operation. double temp = *(double *)val -> data; return (temp * 9.0 / 5.0) + 32.0; } return 0.0; }
1
0
726
Feb ’24
duplicate symbols but Xcode doesn't specify where
I have an Xcode project with an obj-c .c file and a .h file aswell as a .swift file where I am calling functions from those obj-c files with a bridging header but when I build my project I get a duplicate symbols error and Xcode doesn't show where. here is .h header file: #define smc_h #include &lt;stdint.h&gt; #include &lt;mach/mach.h&gt; #include &lt;IOKit/IOKitLib.h&gt; typedef struct { uint32_t datasize; uint32_t datatype; uint8_t data[8]; } SMCVal_t; io_connect_t conn; kern_return_t openSMC(void); kern_return_t closeSMC(void); kern_return_t readSMC(char *key, SMCVal_t *val); double convertToFahrenheit(SMCVal_t *val); #endif /* smc_h */ my .c implementation file: #include "smc.h" kern_return_t openSMC(void) { kern_return_t result; kern_return_t service; io_iterator_t iterator; service = IOServiceGetMatchingServices(kIOMainPortDefault, IOServiceMatching("AppleSMC"), &amp;iterator); if(service == 0) { printf("error: could not match dictionary"); return 0; } result = IOServiceOpen(service, mach_task_self(), 0, &amp;conn); IOObjectRelease(service); return 0; } kern_return_t closeSMC(void) { return IOServiceClose(conn); } kern_return_t readSMC(char *key, SMCVal_t *val) { kern_return_t result; uint32_t keyCode = *(uint32_t *)key; SMCVal_t inputStruct; SMCVal_t outputStruct; inputStruct.datasize = sizeof(SMCVal_t); inputStruct.datatype = 'I' &lt;&lt; 24; //a left shift operation. turning the I into an int by shifting the ASCII value 24 bits to the left inputStruct.data[0] = keyCode; result = IOConnectCallStructMethod(conn, 5, &amp;inputStruct, sizeof(SMCVal_t), &amp;outputStruct, (size_t*)&amp;inputStruct.datasize); if (result == kIOReturnSuccess) { if (val -&gt; datasize &gt; 0) { if (val -&gt; datatype == ('f' &lt;&lt; 24 | 'l' &lt;&lt; 16 | 't' &lt;&lt; 8 )) { //bit shifting to from 32bit operation associated with the ASCII charecters'f', 'l', and 't', sets datatype field. double temp = *(double *)val -&gt; data; return temp; } } } return 0.0; } double convertToFahrenheit(SMCVal_t *val) { if(val -&gt; datatype == ('f' &lt;&lt; 24 | 'l' &lt;&lt; 16 | 't' &lt;&lt; 8 )) { //checking if val-&gt;datatype is equal to the result of the bit-shifting operation. double temp = *(double *)val -&gt; data; return (temp * 9.0 / 5.0) + 32.0; } return 0.0; } And my .swift file where my objc functions are called: import IOKit public class CPUTempCaller { public struct SMCVal_t { var datasize: UInt32 var datatype: UInt32 var data: (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) } @_silgen_name("openSMC") func openSMC() -&gt; Int32 @_silgen_name("closeSMC") func closeSMC() -&gt; Int32 @_silgen_name("readSMC") func readSMC(key: UnsafePointer&lt;CChar&gt;?,val: UnsafeMutablePointer&lt;SMCVal_t&gt;) -&gt; kern_return_t @_silgen_name("convertToFahrenheit") func convertToFahrenheit(val: UnsafePointer&lt;SMCVal_t&gt;) -&gt; Double { let openSM = openSMC() guard openSM == 0 else { print("Failed to open SMC: \(openSM)") return 0.0; } let closeSM = closeSMC() guard closeSM == 0 else { print("could not close SMC: \(closeSM)") return 0.0; } func convertAndPrintTempValue(key:UnsafePointer&lt;CChar&gt;?,scale: Character, showTemp: Bool ) -&gt; Double? { var SMCValue = SMCVal_t(datasize: 0, datatype: 0, data:(0,0,0,0,0,0,0,0)) //initializing SMC value if let Key = key { //check if nil. If not nil, proceed to code block execution let key = "TC0P" let keyCString = (key as NSString).utf8String //passing key as null terminated utf8 string let readSMCResult = readSMC(key: keyCString, val: &amp;SMCValue) //call readSMC obj-C function, store result in "readSMCResult" if readSMCResult != KERN_SUCCESS { print("Failed to read SMC: \(readSMCResult)") } } if showTemp { //return nil if showTemp is false let convertRawToFahrenheit = convertToFahrenheit(val: &amp;SMCValue) let scaleToStr = String(scale) print(String(format: "Temperature: %0.1f °%c", convertRawToFahrenheit, scaleToStr)) return nil } else { print("could not convert temperature and format values in Fahrenheit") return nil } } return 0.0; } }
1
0
444
Feb ’24
CoreData Transformable Types and SecureCoding
I have a CoreData entity with a transformable property data that stores an NSDictionary. All of the classes inside the dictionary conform to NSSecureCoding I have been getting many instances of this warning : 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release In trying to clean up the warning and future-proof my app, but I am running into a lot of trouble. My understanding is that using NSKeyedUnarchiveFromData as the transformer in my data properties attribute should work, since the top level class is a dictionary and all of the contents conform to NSSecureCoding. However, my data dictionary is now coming back as NSConcreteMutableData so I cannot access the data in it. I have also tried creating a custom value transformer with additional allowedTopLevelClasses, but that hasn't helped, and again, the topLevel type is an NSDictionary, which should be allowed. Thank you for any guidance.
3
0
515
Feb ’24
How to read a CMVideoDimensions structure with Objective C code?
I am new to Objective C and relatively new to iOS development. I have an AVCaptureDevice object at hand and would like to print the maximum supported photo dimensions as provided by activeFormat.supportedMaxPhotoDimensions, using Objective C. I tried the following: for (NSValue *obj in device.activeFormat.supportedMaxPhotoDimensions) { CMVideoDimensions *vd = (__bridge CMVideoDimensions *)obj; NSString *s = [NSString stringWithFormat:@"res=%d:%d", vd->width, vd->height]; //print that string } If I run this code, I get: res=314830880:24994 This is way too high, and there is obviously something I am doing wrong, but I don't know what it could be. According to the information I see on the developer forum, I should get something closer to 4000:3000. I can successfully read device.activeFormat.videoFieldOfView and other fields, so I believe my code is sound overall.
1
0
468
Feb ’24
MacOS App crashes when mouse moves over WKWebView, only under Ventura and Sonoma
This is a problem that only exists on MacOS 13 (Ventura) and MacOS 14 (Sonoma). On all earlier versions of MacOS, the existing code works well, and has for many years. I am working on an long-running Objective-C MacOS app (non-sandboxed) that uses WKWebView to display a static web page within a "pane" of a larger NSView. By "pane", I mean the WKWebView might be the only view within the encompassing NSView (thereby occupying all of its space), or it might occupy only one rectangle within it, if the NSView is divided into arbitrary rectangles. (Whether or not the WKWebView takes up the entire surrounding rectangle, or just a section of it, seems irrelevant.) The WKWebView is created offscreen at startup time, and later may become visible under user control. I don't need the displayed web page to permit any interactivity with the user other than scrolling, and I disable Javascript on the page using the WKWebViewConfiguration - which appears to work as intended. I therefore have no need for NSTrackingArea either, and am not using it. It does appear that the WKWebView has one NSTrackingArea by default, but it's not mine. I can remove it programmatically, but that does not appear to make any difference. When the WKWebView is visible, the app will instantly crash as soon as the cursor enters its rectangle. The stack trace shows the error: [_NSTrackingAreaCGViewHelper cursorAreas]: unrecognized selector sent to instance The problem here is that the _NSTrackingAreaCGViewHelper method appears to be something within an Apple internal framework - I can't find discussion of it anywhere on the Internet, or in Apple's developer docs. Same for the selector "cursorAreas" - I can't find any information about it at all. So this is starting to feel like a bug somewhere in Apple's internal framework. I can't understand why it's crashing with a message related to NSTrackingArea (or similar objects), when I'm not using tracking at all, but the "unrecognized selector" error is even more disturbing - I'm not calling the method, and certainly can't control the selector. I can't be sure, but this feels like Apple's error. I'd like to know if there might be a way for me to configure WKWebView to not use tracking at all, thereby eliminating the issue entirely, but I can't find a way to do that other than removing the NSTrackingAreas from the WKWebView, but that's not helping either. Can anyone (especially from Apple) offer any guidance? If it's an Apple bug, I would love to know how to work around it - it's a show-stopper for this app. Thanks in advance...
0
0
390
Feb ’24
Getting Swift_header compilation error for tvOS
I have a tvOS project contains an App target and 3 static libraries: EntryPoint – Static library that contains main , AppDelegate and SceneDelegate Experience – Static library containing my UI elements AppTarget – executable built using above two libraries I have a class "SelectionTable" which subclasses UITableView in Experience target : import UIKit class SelectionTable : UITableView { private var vDataSrc:[String]! func SetDataSrc (_ pDataSrc:[String]) { self.vDataSrc = pDataSrc } func UpdateDataSrc (_ pStringList:[String]) { self.vDataSrc += pStringList } func GetDataSrc () -> [String] { return self.vDataSrc } } I am not using this class anywhere and still i am getting these errors when i build my AppTarget: Cannot find interface declaration for 'UITableView', superclass of 'SelectionTable' Expected a type These above error are coming in generated header file "Experience-Swift.h". This file is auto-generated by compiler. I am not using @objc anywhere in the code, But still the Target-Swift.h file has the below lines: SWIFT_CLASS("_TtC10Experience22SelectionTable") @interface SelectionTable : UITableView - (nonnull instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style OBJC_DESIGNATED_INITIALIZER; - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder OBJC_DESIGNATED_INITIALIZER; @end When i am marking above class as Private , this error goes away . And also , if i am defining SelectionTable class in EntryPoint library , this error does not occur . I am using similar model for an iOS project also and there i am not facing this issue. I am using :- Swift version : Swift 5.9.2 XCode version : 15.2
0
2
543
Feb ’24
NSKeyedUnarchiver decodeObjectOfClasses failed
I tried to read an Object : -(NSMutableDictionary*) readMyObject:(NSData*)data; { NSError * error; Class class = [NSMutableDictionary class]; NSMutableDictionary * dict; dict = [NSKeyedUnarchiver unarchivedObjectOfClass:class fromData:data error:&amp;error]; return dict; the result was nil. I searched by Developer for a solution and found one : { // NSKeyedUnarchiver * unarchiver = [[NSKeyedUnarchiver alloc] init]; [unarchiver decodeObjectOfClasses: [[NSSet alloc]initWithArray: @[[NSDictionary class], [NSMutableDictionary class], [NSArray class], [NSMutableArray class], [NSString class], [NSNumber class]]] forKey:NSKeyedArchiveRootObjectKey]; [unarchiver finishDecoding]; } The first line was from me and it crashed the project. I assume there is an easy answer, not for me.🥲 Uwe
6
0
853
May ’24
"zero length data" error
I had a customer feedback about a "zero length data" error which was captured using an exception handler and displayed using NSAlert. My app employs [NSURLSession dataTaskWithURL:] to download XML and image data. But I got no idea what it is about. I assume it's related to NSData, but this error never happened before (for years). Does anyone have any idea about the source of this error?
2
0
467
Feb ’24
Interpreting QuartzCore Sonoma 14.3 crashes
We are getting many crash reports from users that just updated to Sonoma 14.3 on arm64 macs. We can reproduce these types of crashes on arm64 14.3 machines only (not Intel 14.3, other versions of macOS, etc). A typical crash report: Code Type: arm64 Parent Process: launchd [1] Date/Time: 2024-01-27T15:51:54.999Z Launch Time: 2024-01-27T15:51:43Z OS Version: Mac OS X 14.3.0 (23D56) Report Version: 104 Exception Type: SIGILL Exception Codes: ILL_NOOP at 0x2e23fc03 Crashed Thread: 9 Thread 9 Crashed: 0 QuartzCore 0x0000000188923428 CA::OGL::PathRenderer::PathRenderer(CA::OGL::Context&, CA::Mat2 const&, CA::Bounds const&, bool, bool, bool) + 268 1 QuartzCore 0x0000000188922d90 CA::OGL::PathFiller::PathFiller(CA::OGL::Context&, CA::Mat2 const&, CA::Bounds const&, CA::OGL::PathCubic*, int, CA::OGL::PathRect*, int, CA::OGL::PathFiller::ScanlinePoint*, int, bool, bool) + 48 2 QuartzCore 0x000000018885db28 CA::CG::fill_path(CA::CG::Renderer&, CGPath const*, CA::CG::StrokeParameters const*, CA::Rect const*, CA::ScanConverter::FillRule, CA::Mat2 const&, bool) + 2724 3 QuartzCore 0x00000001887ffe7c CA::CG::DrawOp::render(CA::CG::Renderer&) const + 1520 4 QuartzCore 0x00000001887fce5c CA::CG::Queue::render_callback(void*) + 1472 5 libdispatch.dylib 0x0000000180448910 _dispatch_client_callout + 16 6 libdispatch.dylib 0x000000018044ff74 _dispatch_lane_serial_drain + 952 7 libdispatch.dylib 0x00000001804509d4 _dispatch_lane_invoke + 376 8 libdispatch.dylib 0x000000018045b61c _dispatch_root_queue_drain_deferred_wlh + 284 9 libdispatch.dylib 0x000000018045ae90 _dispatch_workloop_worker_thread + 400 10 libsystem_pthread.dylib 0x00000001805f6114 _pthread_wqthread + 284 11 libsystem_pthread.dylib 0x00000001805f4e30 start_wqthread + 4 Thread 0: 0 libsystem_kernel.dylib 0x00000001805bb5a8 kevent_id + 8 1 libdispatch.dylib 0x000000018046bff4 _dispatch_event_loop_wait_for_ownership + 432 2 libdispatch.dylib 0x0000000180457f94 DISPATCH_WAIT_FOR_QUEUE + 336 3 libdispatch.dylib 0x0000000180457b5c _dispatch_sync_f_slow + 144 4 QuartzCore 0x00000001887e36a0 CABackingStoreGetFrontTexture(CABackingStore*, CGColorSpace*) + 184 5 QuartzCore 0x00000001887d374c -[NSObject(CARenderValue) CA_prepareRenderValue] + 228 6 QuartzCore 0x0000000188a2545c CA::Layer::prepare_contents(CALayer*, CA::Transaction*) + 188 7 QuartzCore 0x00000001887d0798 CA::Layer::prepare_commit(CA::Transaction*) + 276 8 QuartzCore 0x0000000188950e4c CA::Context::commit_transaction(CA::Transaction*, double, double*) + 676 9 QuartzCore 0x00000001887ae8f0 CA::Transaction::commit() + 644 10 AppKit 0x0000000183fdcb18 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 268 11 AppKit 0x0000000184992f04 ___NSRunLoopObserverCreateWithHandler_block_invoke + 60 12 CoreFoundation 0x00000001806d6d80 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32 13 CoreFoundation 0x00000001806d6c6c __CFRunLoopDoObservers + 528 14 CoreFoundation 0x00000001806d629c CFRunLoopRun + 772 15 CoreFoundation 0x00000001806d593c CFRunLoopRunSpecific + 604 16 HIToolbox 0x000000018ac9e448 RunCurrentEventLoopInMode + 288 17 HIToolbox 0x000000018ac9e0d8 ReceiveNextEventCommon + 216 18 HIToolbox 0x000000018ac9dfdc _BlockUntilNextEventMatchingListInModeWithFilter + 72 19 AppKit 0x0000000183eb4ed0 DPSNextEvent + 656 20 AppKit 0x000000018469feec -[NSApplication(NSEventRouting) nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 712 21 AppKit 0x0000000183ea837c -[NSApplication run] + 472 22 acord 0x0000000100c45290 P110TARGETAPP$$TTARGETAPPLICATION$$$_EVENTLOOP (p110TargetApp.pas:5781) 23 acord 0x0000000100bc82e8 PASCALMAIN (Accord.pas:154) 24 acord 0x000000010159ab40 FPC_SysEntry + 28 25 acord 0x000000010156f770 FPC_SYSTEMMAIN + 76 26 acord 0x0000000100bc814c main + 8 27 ??? 0x00000001802790e0 0x0 + 0 {....} Thread 14: 0 ??? 0x0000000000000000 0x0 + 0 Thread 9 crashed with arm64 Thread State: x21: 0x000000016f7bb270 x2: 0x0000000169a00658 x16: 0x00000001887fef60 x3: 0x000000016f7b6a20 x22: 0x000000016f7b6a20 x4: 0x0000000000000000 x17: 0x00000001887feeb0 cpsr: 0x0000000060001000 x5: 0x0000000000000000 x23: 0x0000000000000000 x6: 0x0000000000000001 x18: 0x0000000000000000 x10: 0x0000000188af7000 lr: 0x0000000188922d90 x7: 0x0000000000000000 x24: 0x0000000169a00658 x11: 0x0000000000000000 x8: 0x0000000000000007 x19: 0x000000016f7b6a70 x25: 0x0000000188b0d968 x9: 0x0000000000000001 x12: 0x0000000000000008 fp: 0x000000016f7b6960 x26: 0x000000016f7ca270 x13: 0x0000000000000009 pc: 0x0000000188923428 x27: 0x0000000000000001 x14: 0x0000000000000001 x20: 0x000000016f7b8a70 x0: 0x000000016f7ca270 sp: 0x000000016f7b6940 x28: 0x0000000000000000 x15: 0x0000000000000012 x1: 0x0000000144808e00 In Xcode we might see a divide by zero like: 0x189247428 <+268>: fdiv EXC_BAD_INSTRUCTION (code=1, subcode=0x2e23fc03) Any help with interpreting/debugging this type of crash would be appreciated.
2
0
408
Feb ’24
TableView.makeView question
Is it possible that I bypass tableView.makeView so that I can create a NSTableCellView on the fly (based on some logics)? func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -&gt; NSView? { if NSTableColumn.identifier.rawValue == "labelColumn" { let myCellView = NSTableCellView() myCellView.textField.strinValue = "label text" return myCellView } else { let complexView = loadFromNib() // of NSTableCellView // populate complexView return complexView } }
0
0
277
Jan ’24
is it possible to operate `NEDNSProxyProvider` transparent mode
My macOS application utilizing NEDNSProxyProvider. i have a requirement to intercept only DNS requests of a certain query type, while others are expected to continue to their respective origin. For TCP there are two kinds of extensions NEAppProxyProvider and NETransparentProxyProvider. The latter is capable of returning NO from handleNewFlow causing the flow to proceed to communicate directly with the flow’s ultimate destination, instead of closing the flow. Is there a way to configure NEDNSProxyProvider to work in transparent mode for letting the flow to proceed to communicate directly? Current NEDNSProxyProvider limitation of dropping the connection when NO is returned requies me to open new socket and proxy the requests which causes noticable performance degradation under load.
2
0
411
Jan ’24
Xcode 15.2 - ObjC Swift Bridging broken?
I have an older project with a mixed ObjC + Swift codebase. I'm in the process of converting everything to Swift in the hopes that Xcode will work better again when the Codebase is not mixed anymore. This is an example of the issues I'm currently facing: The class IVMapViewController is defined in ObjC and the property mapViewModel is declared in the ObjC Header fine. The ObjC Header file is included in the bridging header. I'm trying to access the property mapViewModel in an swift extension on the same class. I can actually compile & run the code just fine, but Xcode Autocompletion does not work, and Xcode generates "Phantom" errors in the Issue Navigator (those errors also stay there when a build completes successful) On the other hand, if I put an actual error in the code, compilation fails, but the actual error will NOT show up in the Issue Navigator. I'll have to dig through the build log to find the actual error. Am I doing anything wrong? Do I need to adjust some project setting?
0
0
331
Jan ’24
Xcode cannot recognize generic methods
In objective-c, I created a category, like @interface NSArray <__covariant ObjectType> (ppEx) @end Look at this ObjectType, I wrote a method like - (NSArray *)pp_map:(id(^)(ObjectType element))block;which act like the map function in Swift. you can call it like NSArray <NSString *>*values = @[@"1", @"2", @"3", @"4"]; NSArray *valueMap = [values pp_map:^id _Nonnull(NSString * _Nonnull element) { return [NSString stringWithFormat:@"Hello %@", element]; }]; Now I need to add a property like mapBlock, I want to realize the same func; @property (nonatomic, copy) NSArray *(^mapBlock)(id(^paramBlock)(ObjectType element)); I did it. But when I call this method in Xcode, it can't complete automatically. values.mapBlock(^id _Nonnull(ObjectType _Nonnull element) { }) It's unable to recognize type NSString, and always show ObjectType which can cause error. I can manually change it to NSString, but it's too complicated. I think it's a problem of Xcode. Can anybody help me?
1
0
358
Jan ’24
Capabilities of Sensitive Content Analysis and iOS 17?
Hello. I have three questions about the Sensitive Content Analysis (SCA) framework: SCA seems to be asynchronous. Is there a limit to how much a single app can send through it at a time? For video analysis, can the video be broken into smaller chunks, and then all chunks be hit concurrently? Can a video stream be sampled as it's being streamed? e.g. Maybe it samples one frame every 3 seconds and scans those? Thanks.
0
0
416
Jan ’24
Hashable class extending NSObject?
I have some Swift classes in my project that extend an Objective-C base class, which in turn extends NSObject. I did this years ago when Swift was new in order to take advantage of some Objective-C code that was difficult to rewrite in Swift. It's not a common situation but it has been working fine for a long time. One of these classes is used as the key to a Dictionary and thus needs to be Hashable. The way I did this was to implement an == function and override the 'hash' property. It is a very simple case where the identity of the object is based on a single integer: static func == (lhs: FishModel, rhs: FishModel) -> Bool { return lhs.fishId == rhs.fishId } override var hash: Int { return fishId } I believe that I initially tried to add "Hashable" to the class definition but was told it was redundant. I'm not sure why that is, but it worked fine without it. Today I took the latest Xcode update to 15.2, and now my project won't compile anymore. The compiler error says that my class "does not conform to protocol Hashable". Adding Hashable to the class definition did not fix it. There are also some unusual errors about missing files, such as abi.json, swiftdoc, swiftmodule, and swiftsourceinfo. Was this caused by the Xcode update? How do I fix it?
2
0
499
Jan ’24