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
1 Replies
442 Views
I am a hobbyist programmer and I have been fooling around with Metal. In getting my feet wet in metal I have found that there is a pretty big gap between the HelloTriangle and DeferredLighting sample code from Apple and a more intermediate sample would be helpful. I have stumbled along through the brush and put together a little app that I thought that other novice metal programmers might find interesting. Features: Vertex buffer creation in Object Space. Composing objects into a scene in Model Space. Transforming a scene in Model Space to Clip Space Hit Testing / Mouse Picking Two pass rendering to produce shadows. I have put the project on GitHub for others to peruse: github.com/MackenzieBD/Sample-Code/blob/main/MetalDemo.zip
Posted
by
Post not yet marked as solved
1 Replies
304 Views
The didFinishWithResult delegate method of MFMessageComposeViewController shows that the message has been sent successfully, even when the device is in airplane mode or when the device has no SIM,but the message sending is failed.The delegate does not go through the failure state.Why doesnt it go to failure state?.Please give me some suggestion on this. The code is given as below: { 		MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; 		picker.messageComposeDelegate = self; 		 		// You can specify one or more preconfigured recipients.	The user has 		// the option to remove or add recipients from the message composer view 		// controller. 		/* picker.recipients = @[@"Phone number here"]; */ 		 		// You can specify the initial message text that will appear in the message 		// composer view controller. 		picker.body = @"Hello from California!"; 		 		[self presentViewController:picker animated:YES completion:NULL]; } // //	messageComposeViewController:didFinishWithResult: //	Dismisses the message composition interface when users tap Cancel or Send. //	Proceeds to update the feedback message field with the result of the //	operation. // (void)messageComposeViewController:(MFMessageComposeViewController *)controller 							didFinishWithResult:(MessageComposeResult)result { 		self.feedbackMsg.hidden = NO; 		// Notifies users about errors associated with the interface 		switch (result) 		{ 				case MessageComposeResultCancelled: 						self.feedbackMsg.text = @"Result: SMS sending canceled"; 						break; 				case MessageComposeResultSent: 						self.feedbackMsg.text = @"Result: SMS sent"; 						break; 				case MessageComposeResultFailed: 						self.feedbackMsg.text = @"Result: SMS sending failed"; 						break; 				default: 						self.feedbackMsg.text = @"Result: SMS not sent"; 						break; 		} 		 		[self dismissViewControllerAnimated:YES completion:NULL]; } For me and other multiple devices when we press "CANCEL" or "SEND" message the correct delegates are fired. But when I switch ON the AIRPLANE Mode or the device with no SIM still the MessageComposeResultSent Is fired. Can some one tell clearly when the MessageComposeResultFailed is fired? Any live steps? Please kindly help me This is my last hope. I just want know when the Status Failed gets fired with step by step procedure
Posted
by
Post not yet marked as solved
1 Replies
430 Views
Hi all, I'm currently implementing a feature that performs customized behavior in each desktop (space). As far as I know, Apple does not have an API that can enumerate all spaces under each screen. I've only found a way that can get all spaces, but cannot find any method on how to determine each space belongs to which screen. Can somebody help me out? Thanks in advance.
Posted
by
Post not yet marked as solved
2 Replies
920 Views
I want graphics card details using objective c. used IOServiceGetMatchingServices api for it, its working fine in Intel processor machine, but not returning model info for M1 machine. here is the code I was using    CFMutableDictionaryRef matchDict = IOServiceMatching("IOPCIDevice");        io_iterator_t iterator;        if (IOServiceGetMatchingServices(kIOMasterPortDefault,matchDict,                    &iterator) == kIOReturnSuccess)   {      io_registry_entry_t regEntry;            while ((regEntry = IOIteratorNext(iterator))) {        CFMutableDictionaryRef serviceDictionary;        if (IORegistryEntryCreateCFProperties(regEntry,                          &serviceDictionary,                           kCFAllocatorDefault,                           kNilOptions) != kIOReturnSuccess)       {          IOObjectRelease(regEntry);          continue;       }        const void *GPUModel = CFDictionaryGetValue(serviceDictionary, @"model");                if (GPUModel != nil) {          if (CFGetTypeID(GPUModel) == CFDataGetTypeID()) {            NSString *modelName = [[NSString alloc] initWithData:                       (NSData *)GPUModel encoding:NSASCIIStringEncoding];                        NSLog(@"GPU Model: %@", modelName);           [modelName release];         }       }        CFRelease(serviceDictionary);        IOObjectRelease(regEntry);     }      IOObjectRelease(iterator);   }
Posted
by
Post not yet marked as solved
2 Replies
1.2k Views
hello i am using cncopycurrentnetworkinfo for getting the data (ssid,bssid) for the connected wifi network but according to the link https://developer.apple.com/documentation/systemconfiguration/1614126-cncopycurrentnetworkinfo showing Deprecated and showing possible solution is using the method fetchCurrentWithCompletionHandler:(https://developer.apple.com/documentation/networkextension/nehotspotnetwork/3666511-fetchcurrentwithcompletionhandle) this is method of HotspotHelper and i also email networkextension@apple.com ask for that entitlement (com.apple.developer.networking.HotspotHelper) used by HotspotHelper but got rejected. i don't know why because i use network info for the connection between IOT display and wifi router using mobile app. so is there any other possible solution?
Posted
by
Post not yet marked as solved
1 Replies
412 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
by
Post not yet marked as solved
33 Replies
10k Views
Hi, Apps crashed when enter foreground and want to connect with server,since iOS 14.5 released on April 27。 Crash stack like this: Monitor Type: Mach Exception Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000010 Crashed Thread: 40 Pthread id: 867350 Thread 40 Crashed: 0 libnetwork.dylib nw_endpoint_flow_copy_path + 44 1 libnetwork.dylib nw_endpoint_flow_copy_path + 40 2 libnetwork.dylib nw_endpoint_flow_connected + 320 3 libnetwork.dylib nw_flow_connected + 3668 4 libnetwork.dylib nw_socket_connect + 584 5 libnetwork.dylib nw_endpoint_flow_connect + 164 6 libnetwork.dylib nw_endpoint_flow_setup_protocols + 3272 7 libnetwork.dylib -[NWConcrete_nw_endpoint_flow startWithHandler:] + 3616 8 libnetwork.dylib nw_endpoint_handler_path_change + 10592 9 libnetwork.dylib nw_endpoint_handler_start + 1184 10 libnetwork.dylib __nw_connection_start_block_invoke + 1460 11 imeituan __innerBlockOnce_block_invoke (SCRCrashMonitor_GCD.mm:191) 12 libdispatch.dylib _dispatch_call_block_and_release + 32 13 libdispatch.dylib _dispatch_client_callout + 20 14 libdispatch.dylib _dispatch_lane_serial_drain + 620 15 libdispatch.dylib _dispatch_lane_invoke + 456 16 libdispatch.dylib _dispatch_workloop_invoke + 1680 17 libdispatch.dylib _dispatch_workloop_worker_thread + 764 18 libsystem_pthread.dylib _pthread_wqthread + 276 Enqueue thread backtrace: 0 imeituan innerBlockOnce (SCRCrashMonitor_GCD.mm:0) 1 imeituan _dispatch_async (SCRCrashMonitor_GCD.mm:0) 2 libnetwork.dylib nw_connection_start + 280 3 libnetwork.dylib tcp_connection_start + 1496 4 CFNetwork 0x0000000180b7c3bc + 168 5 CFNetwork 0x0000000180b79b80 + 2776 6 CFNetwork 0x0000000180b77918 + 1724 7 CoreFoundation _CFStreamOpen + 140 8 imeituan -[GCDAsyncSocket openStreams] (GCDAsyncSocket.m:6998) 9 imeituan __29-[GCDAsyncSocket didConnect:]_block_invoke330 (GCDAsyncSocket.m:2369) 10 imeituan __29-[GCDAsyncSocket didConnect:]_block_invoke_2 (GCDAsyncSocket.m:2396) 11 imeituan __innerBlockOnce_block_invoke (SCRCrashMonitor_GCD.mm:191) 12 libdispatch.dylib _dispatch_call_block_and_release + 32 13 libdispatch.dylib _dispatch_client_callout + 20 14 libdispatch.dylib _dispatch_lane_serial_drain + 620 15 libdispatch.dylib _dispatch_lane_invoke + 404 16 libdispatch.dylib _dispatch_workloop_worker_thread + 764 17 libsystem_pthread.dylib _pthread_wqthread + 276 18 libsystem_pthread.dylib start_wqthread + 8
Posted
by
Post not yet marked as solved
7 Replies
2.7k Views
Xcode - Window - Organizer - Reports - Crashes I found some unwonted crash which contains information of NO_CRASH_STACK. LocallySymbolicated crash log 1 - https://developer.apple.com/forums/content/attachment/4b77d9ae-075e-4d77-a641-af4510e9c459 LocallySymbolicated crash log 2 - https://developer.apple.com/forums/content/attachment/2baac532-a7a7-4fcd-b9d4-b016aed176b5
Posted
by
Post not yet marked as solved
2 Replies
1.3k Views
Hello Team, I am facing the clang error when I am trying to run the source in Xcode 12.5 BUT it is working fine in 11.4 In file included from :1: PrefixHeader.pch:15:2: fatal error: malformed or corrupted AST file: 'mismatched umbrella headers in submodule' #import <FAPL/FAPL.h> ^ clang: error: unable to execute command: Segmentation fault: 11 clang: error: clang frontend command failed due to signal (use -v to see invocation) Apple clang version 12.0.0 (clang-1200.0.32.29) Target: x86_64-apple-ios10.0-simulator Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin clang: note: diagnostic msg: PLEASE submit a bug report to http://developer.apple.com/bugreporter/ and include the crash backtrace, preprocessed source, and associated run script. clang: error: unable to execute command: Segmentation fault: 11 clang: note: diagnostic msg: Error generating preprocessed source(s).
Posted
by
Post not yet marked as solved
0 Replies
1.3k Views
Hi! I've been trying to precompile one of our internal modules for a while, but I can't figure out how to get this done. Info Let's call the library I'm trying to precompile InternalLib. InternalLib is a mixed Swift/Objc static library, that depends on SwiftProtobuf and Protobuf. Our project use InternalLib as dependency. So far I've successfully done these steps: Step 1: Archive InternalLib The Example app in InternalLib fetches the dependencies correctly, and a script generates archives the library from the InternalLib-ExampleApp.xcworkspace. The result are 2 archives (iOS and simulator), compiled with this xcconfig: SKIP_INSTALL = NO BUILD_LIBRARY_FOR_DISTRIBUTION = YES SWIFT_OPTIMIZATION_LEVEL = -Osize OTHER_SWIFT_FLAGS = $(inherited) -verify-emitted-module-interface GCC_PREPROCESSOR_DEFINITIONS = $(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1 Step 2: Generate xcframework The next step is generating the xcframework. For this step we have the following script: function create_xcframework { for NAME in "InternalLib" "Protobuf" "SwiftProtobuf" do xcodebuild -create-xcframework \ -framework archives/InternalLib-iOS_sim.xcarchive/Products/Library/Frameworks/$NAME.framework \ -framework archives/InternalLib-iOS.xcarchive/Products/Library/Frameworks/$NAME.framework \ -output products/universal/$NAME.xcframework done } ..which successfully generates 3 XCFrameworks. Step 3: Run cocoapods At this step we regenerate the full project setup, and use cocoapods to connect each module to its dependencies. I've tried a few configurations: dependencies fetched via cocoapods, and specifying the resulting XCFrameworks as separate Podspecs, in order to create the dependencies by having the InternalLib.xcframework depending on XCFrameworks only. Both solutions fail in the same terms. Issues: Preprocessor flags not available: When I compile, the compiler flags present in InternalLib configuration seem unavailable. In this specific case, the headers are trying to resolve the Protobuf dependencies via local #include "Header.h", instead of going to #include <Protobuf/Header.h>, like so, even if the GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS flag is set in the project's preprocessor flags. # #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS # #import <Protobuf/GPBProtocolBuffers.h> # #else # #import "GPBProtocolBuffers.h" # #endif Missing symbols: By overriding the headers in order to forcefully use #import <Protobuf/GPBProtocolBuffers.h>, we get to the very end of the project compilation, just to fail with Undefined Symbol SwiftProtobuf.[...], which means the library of which InternalLib depends on was not found. My questions here are: Why is the preprocessor flag not seen while compiling the app? is this this configuration of having a XCFramework depend on cocoapods libs not supported? I am not sure if this is the best place to ask these questions, as it's using a 3rd party dependency manager, but maybe someone has tried a similar configuration in their project. Thanks!
Posted
by
Post not yet marked as solved
1 Replies
248 Views
Hi folks, I'm trying to find a way to check if several of my table cells are really being seen by users (let's say, if the cell is at least 1px shown, I consider it as being seen). And also need to make sure if users scroll up and down, I'll need to trigger the method. (This should be easy as I can put the check in listener method like DidScroll or something) Seems like using indexPathsForVisibleRows can only give me rows that are almost 100% visible in the screen. I'm searching for solutions, and looks like using rectForRowAtIndexPath and doing some math with contentOffset may give me what I want. Not sure if there's better way. Anyone could help? Thanks very much!
Posted
by
Post not yet marked as solved
0 Replies
523 Views
Hi, I am developing an application in Objective-C in which at a given moment I have to play samples (its duration is 1 second aprox) when the user hits a pad of his instrument (which has several pads). I receive the notes through a MIDI interface (CoreMIDI-Wrapper, available in Github) and to play the samples I'm doing the following: Previously I have an AVAudioEngine instantiated and in its mixer node (AVAudioMixerNode) I have attached 16 AVAudioPlayerNode. I have an integer (iCurrentNode ranging from 0 to 15) that points to the current AVAudioPlayerNode. When the user hits a pad I do: [aAVAudioPlayerNode[iCurrentNode] scheduleBuffer:PCMbuffer_note atTime:nil completionHandler{}]; iCurrentNode++; if(iCurrentNode == 16)iCurrentNode = 0; The reason for the 16 playback nodes is that scheduleBuffer does not allow overlapping sounds. Therefore, if the user hits a pad and hits it again before the first sound has finished playing, that is queued instead of being overlapped. The implementation gives me too lag on iPad Pro 10,5" (about half a second). I think I have done a bad approach to the problem... Somebody could help me? Thanks
Posted
by
Post marked as solved
6 Replies
783 Views
class  a {     b().download ({ data in     }) } class  b{     func download (downloadedData: @escaping (_ data: Data? ) -&gt; Void )  {         c().download()     } } class c {     func download () -&gt; Data {         let semaphore = DispatchSemaphore(value: 0)           NetworkManager().downloadRequest: { (result: Result&lt;Data, Error&gt;) in                                             switch result {                                             case .success(let success)                                                 ......                                              case .failure(let error): .....                                             }                                             semaphore.signal()                                    }                         )         semaphore.wait()         return data     } } Class a initiates the download and class c interacts with network manager to download the data. Class c issues semaphore wait as soon as it sends request to download the data and issues signal when download completes. Is there a way to issue signal from class a when download is in progress. Basically class a should be able to skip wait by issuing signal command
Post not yet marked as solved
0 Replies
346 Views
Hello everyone! I am adding in my react native project the CarPlay framework via native code and in PointOfInterest I want to add the 'primaryButton' on the 'Details Card'. So as I saw in the docs (https://developer.apple.com/documentation/carplay/cppointofinteresttemplate?language=objc) there is the property of 'primaryButton' for this template but it's not added somehow on CPPointOfInterest when 'Creating a PointOfInterest template'.. So how can I added...? Any help is welcome :)
Post not yet marked as solved
0 Replies
401 Views
I'm converting an existing iOS framework to a Swift package; it is being consumed by an IOS app. The Swift package (which contains a mix of Obj-C, Obj-C++, and C++) compiles and I can run unit tests against it. When I try building the app and link against the package, I get a very large number of "duplicate symbol" errors, where the symbols in question are also found in other packages consumed by the app. What I don't understand is that most of these symbols should be completely hidden. In one example from the new package, I have essentially the case below (simplified here): // MyFile.h //(include guards) int doSomething(); // MyFile.cpp #include "MyFile.h" int localFunction() { int result = 0; // do some processing, set result to 0 or 1; return result; } int doSomething() { // do some processing // ... // check an intermediate result if (localFunction() == 0) { return 0; } // do some other stuff return 1; } and yet localFunction is reported as one of the duplicate symbols, because another Swift Package uses the same source file, where that symbol should also be completely hidden. The client app sets the -ObjC linker flag; I have seen where this causes the same (or at least very similar) behavior and was considered a bug (https://developer.apple.com/forums/thread/106694). I am using Xcode 13 Beta and Xcode 13.2 beta, and get the same issue with both. Bug in Xcode? Flaw in my handling/understanding? (Is this related to the ObjC flag, and correctly so?)
Posted
by
Post not yet marked as solved
2 Replies
650 Views
Hi, I'm new to programming and learning to write code in C for my degree. I'm comfortable with the code side of things, however struggling to get my head around the layout of Xcode and creating projects etc. Is it possible to create a project with multiple 'programmes' within it? For example I create a project for 'Monday's lecture' that I have several separate source codes in it that are independent of each other to cover each aspect of the lecture? Also how do I get my programme to compile and run in terminal rather than the window at the bottom of Xcode's? Thanks
Posted
by
Post not yet marked as solved
1 Replies
872 Views
Hi I want to use AES-GCM encryption of a plaintext with 'key' only. The 'key' will be received from backend (.net), in webservice response. The same key will be used later in backend as well to decrypt the encrypted value. I have used extension as follwoing To generate string to Symetric key extension SymmetricKey { init(string keyString: String, size: SymmetricKeySize = .bits256) throws { guard var keyData = keyString.data(using: .utf8) else { print("Could not create base64 encoded Data from String.") throw CryptoKitError.incorrectParameterSize } let keySizeBytes = size.bitCount / 8 keyData = keyData.subdata(in: 0..<keySizeBytes) guard keyData.count >= keySizeBytes else { throw CryptoKitError.incorrectKeySize } self.init(data: keyData) } } Encryption & Decryption code snipet: func aesgcmEncryptDecrypt() { let str : String = "FwhXRYJ$xLf?^Kh6_&YfTJ%RuG+EqcTY" var key : SymmetricKey = SymmetricKey(size: .bits256) do{ key = try SymmetricKey(string: str) }catch{ } let plain = "HOW ARE YOU?" let nonce = try! AES.GCM.Nonce(data: Data(base64Encoded: "fv1nixTVoYpSvpdA")!) let tag = Data(base64Encoded: "e1eIgoB4+lA/j3KDHhY4BQ==")! // Encrypt let sealedBox = try! AES.GCM.seal(plain.data(using: .utf8)!, using: key, nonce: nonce, authenticating: tag) // Decrypt let sealedBoxRestored = try! AES.GCM.SealedBox(combined: sealedBox.combined!) let decrypted = try! AES.GCM.open(sealedBoxRestored, using: key, authenticating: tag) Swift.print("Combined:\n(sealedBox.combined!.base64EncodedString())\n") Swift.print("Cipher:\n(sealedBox.ciphertext.base64EncodedString())\n") Swift.print("Nonce:\n(nonce.withUnsafeBytes { Data(Array($0)).base64EncodedString() })\n") Swift.print("Tag:\n(tag.base64EncodedString())\n") Swift.print("Decrypted:\n(String(data: decrypted, encoding: .utf8)!)\n") } Our(generated from this code & .Net code) encrypted text is not matching. Anyone can help me, what I am doing wrong, detailing will be more helpful. Basically I was looking for saloution in Objective-C but I did not get any supported library for Objective-C.
Posted
by