Im getting a duplicate symbols error when I build my Xcode project and Xcode doesn't specify what or where in my code is there a duplicate:
"1 duplicate symbols" "Showing Recent Issues Linker command failed with exit code 1 (use -v to see invocation)
"
#include <stdio.h>
#include <IOKit/IOKitLib.h>
typedef struct {
uint32_t datasize;
uint32_t datatype;
uint8_t data[32];
} SMCVal_t;
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'
float temp = *(float *)val -> data;
return temp;
}
}
}
return 0.0;
}
double getTemperature(char *key) {
SMCVal_t val;
kern_return_t result;
result = readSMC(key, &val);
if(result == kIOReturnSuccess) {
if (val.datasize > 0) {
printf("val.datasize: %u\n", val.datasize);
if (val.datatype != 0) {
double temperature = (double)val.data[0];
return temperature;
}
}
}
return 0.0;
}
double convertToFahrenheit(double Fahrenheit) {
return (Fahrenheit * (9.0 / 5.0)) + 32.0;
}
int main(void) {
kern_return_t result;
result = openSMC();
if(result == kIOReturnSuccess) {
double temp = getTemperature("TC0P");
double temperatureInFahrenheit = convertToFahrenheit(temp);
printf("temp: %.2f\n", temperatureInFahrenheit);
result = closeSMC();
}
return 0;
}
Objective-C
RSS for tagObjective-C is a programming language for writing iOS, iPad OS, and macOS apps.
Posts under Objective-C tag
191 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have a need to optimize reading strategy, based on if the file is on hard disk or SSD. Does macOS provide any low-level API so that I can query such information?
I have a C file for accessing the apple smc and I have the corresponding header file with my declarations in it but when I build my Xcode project I get the error:
"ld: Undefined symbols:
_getTemperature, referenced from:
_main in getsmc.o
clang: error: linker comm"
#include <stdio.h>
#include <IOKit/IOKitLib.h>
typedef struct {
uint32_t datasize;
uint32_t datatype;
uint8_t data[32];
} SMCVal_t;
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);
}
double getTemperature(char *key);
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 )) {
float temp = *(float *)val -> data;
return temp;
}
}
}
return 0.0;
}
int main(void) {
kern_return_t result;
result = openSMC();
if(result == kIOReturnSuccess) {
double temp = getTemperature("TC0P");
printf("temp: %.2f\n", temp);
result = closeSMC();
}
return 0;
}
I am working on the project in which we are migrating from iOS project to framework. I am facing issue with Objective-C and swift interoperability.
I have one Swift class let suppose profile, it has been exposed to objective c
import Foundation
@objc public class Profile: NSObject {
@objc public var name : String?
@objc public func getName() -> String{
return "XYZ"
}
}
When I am importing “ProductName-Swift.h” it is showing me error in generated header for the module map like “@import ModuleMapPrivate not found”
I wanted to know is there any way in which I can import “Profile-Swift.h” instead of “ProductName-Swift.h” ?
Date/Time: 2023-12-22 10:15:42.0985 +0800
Launch Time: 2023-12-22 10:12:52.8757 +0800
OS Version: iPhone OS 17.1.2 (21B101)
Release Type: User
Baseband Version: 4.06.02
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 3131951633
&lt;RBSTerminateContext| domain:10 code:0xBAADCA11 explanation: reportType:CrashLog maxTerminationResistance:Interactive&gt;
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x1e6bfc1d8 mach_msg2_trap + 8
1 libsystem_kernel.dylib 0x1e6bfbf70 mach_msg2_internal + 79
2 libsystem_kernel.dylib 0x1e6bfbe88 mach_msg_overwrite + 435
3 libsystem_kernel.dylib 0x1e6bfbcc8 mach_msg + 23
4 CoreFoundation 0x19f725d0c __CFRunLoopServiceMachPort + 159
5 CoreFoundation 0x19f723c04 __CFRunLoopRun + 1207
6 CoreFoundation 0x19f723668 CFRunLoopRunSpecific + 607
7 GraphicsServices 0x1e2aee5ec GSEventRunModal + 163
8 UIKitCore 0x1a1b402b4 -[UIApplication _run] + 887
9 UIKitCore 0x1a1b3f8f0 UIApplicationMain + 339
10 iCSee 0x103921380 main + 115 (main.m:17)
11 dyld 0x1c2176dcc start + 2239
I am trying to get the raw audio data from the system microphone using AudioToolbox and CoreFoundation frameworks. So far the writing packets to file logic works but when I try to capture the raw data into a file I am getting white noise.
Callback function looks like this:
static void MyAQInputCallback(void *inUserData, AudioQueueRef inQueue,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp *inStartTime,
UInt32 inNumPackets,
const AudioStreamPacketDescription *inPacketDesc)
{
MyRecorder *recorder = (MyRecorder *)inUserData;
if (inNumPackets > 0)
{
CheckError(AudioFileWritePackets(recorder->recordFile, FALSE, inBuffer->mAudioDataByteSize,
inPacketDesc, recorder->recordPacket, &inNumPackets,
inBuffer->mAudioData), "AudioFileWritePackets failed");
recorder->recordPacket += inNumPackets;
int sampleCount = inBuffer->mAudioDataByteSize / sizeof(AUDIO_DATA_TYPE_FORMAT);
AUDIO_DATA_TYPE_FORMAT* samples = (AUDIO_DATA_TYPE_FORMAT*)inBuffer->mAudioData;
FILE *fp = fopen(filename, "a");
for (int i = 0; i < sampleCount; i++){
fprintf(fp, "%i;\n",samples[i]);
}
fclose(fp);
}
if (recorder->running)
CheckError(AudioQueueEnqueueBuffer(inQueue, inBuffer, 0, NULL), "AudioQueueEnqueueBuffer failed");
}
Some parameters:
NumberRecordBuffers = 3
buffer duration = 0.1
format->mFramesPerPacket = 4096
samplerate = 44100
inNumPackets = 1
recordFormat.mFormatID = kAudioFormatAppleLossless;
recordFormat.mChannelsPerFrame = 1;
recordFormat.mBitsPerChannel = 16;
Is this the correct way to do this? I could not find much information in the documentation. Any help is appreciated. Thank you in advance.
I have this code to create an IOSurface from a bitmap image:
auto src = loadSource32f(); // rgba 32-bit float image
const auto desc = src->getDescriptor(); // metadata for that image
auto pixelFmt = CGMTLBufferManager::getCVPixelFormat( desc.channelBitDepth, desc.channelOrder ); // returns proper `RGfA`
int width = static_cast<int>( desc.width );
int height = static_cast<int>( desc.height );
int trowbytes = static_cast<int>( desc.trueRowbytes() ); // returns proper rowbytes value
CFMutableDictionaryRef properties = CFDictionaryCreateMutable(
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
CFDictionarySetValue(
properties, kIOSurfaceWidth, CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &width ) );
CFDictionarySetValue(
properties, kIOSurfaceHeight, CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &height ) );
CFDictionarySetValue(
properties, kIOSurfacePixelFormat, CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &pixelFmt ) );
CFDictionarySetValue(
properties, kIOSurfaceBytesPerRow, CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &trowbytes ) );
NSDictionary *nsprops = ( __bridge NSDictionary * )properties;
IOSurface *oSurface = [[IOSurface alloc] initWithProperties:nsprops];
CFRelease( properties );
ASSERT_TRUE( oSurface );
auto ioSurface = (IOSurfaceRef) oSurface;
I tested that the pixels are properly written into the iosurface:
// copy data to surface
memcpy([oSurface baseAddress], src->getRawPtr(), src->getSizeInBytes());
auto surfPtr = (uint8_t*)[oSurface baseAddress];
// extract raw surface data and write it into a file
saveOutputRaw(desc, surfPtr, getFileName("IOSurfaceTestSurfaceRaw"));
And I see this:
Now I want to create a MTLTexture based on the iosurface:
// create texture
auto fmt = IOSurfaceGetPixelFormat( ioSurface );
auto w = IOSurfaceGetWidth( ioSurface );
auto h = IOSurfaceGetHeight( ioSurface );
auto rowbytes = IOSurfaceGetBytesPerRow( ioSurface );
MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:CGMTLBufferManager::getMTLPixelFormat( fmt )
width:w
height:h
mipmapped:NO];
textureDescriptor.usage = MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite;
textureDescriptor.storageMode = MTLStorageModeShared;
auto device = MTLCreateSystemDefaultDevice();
id<MTLTexture> surfaceTex = [device newTextureWithDescriptor:textureDescriptor iosurface:ioSurface plane:0];
And now I want to test this:
auto region = MTLRegionMake2D(0, 0, w, h);
auto bufSize = [oSurface allocationSize];
// get texture bytes
auto outBuf2 = std::vector<uint8_t>(bufSize);
[surfaceTex getBytes:outBuf2.data()
bytesPerRow:rowbytes
fromRegion:region
mipmapLevel:0];
// save to file
saveOutputRaw(desc, outBuf2.data(), getFileName("IOSurfaceTestCreateTex"));
// get bytes
saveOutputRaw(desc, surfPtr, getFileName("IOSurfaceTestCreateRaw"));
And I get this result:
I also tried replaceRegion and blitEncoder copyFromTexture: toTexture: as well as managed texture with syncing, but the result is always the same - only the first 22 pixels get filled and the rest is transparent.
I have no idea what I'm missing. Please help.
I have a single-line label whose purpose is display file path, possibly very long.
Is there any way to shorten/compact the path string (with ellipse ...) so that the label still displays full path even it's too long?
Like below:
/some/very/long/path/to/some/filename.txt
to
/some/.../filename.txt
I have an overloaded function, one version with a BOOL parameter and one with a bool parameter. It gives me a redefinition error when compiling for Apple Silicon but not when compiling for Intel.
I tried to archive a NSDictionary with a NSColor :
data = [NSKeyedArchiver archivedDataWithRootObject: <vrRoot> requiringSecureCoding:YES error:&error];
and I get this error :
Printing description of error:
Error Domain=NSCocoaErrorDomain Code=4864 "value for key 'NS.objects' was of unexpected class 'NSColor' (0x7ff8465d0d88) [/System/Library/Frameworks/AppKit.framework].
Allowed classes are:
{(
"'NSMutableDictionary' (0x7ff8465f9b48) [/System/Library/Frameworks/CoreFoundation.framework]"
)}" UserInfo={NSDebugDescription=value for key 'NS.objects' was of unexpected class 'NSColor' (0x7ff8465d0d88) [/System/Library/Frameworks/AppKit.framework].
Allowed classes are:
{(
"'NSMutableDictionary' (0x7ff8465f9b48) [/System/Library/Frameworks/CoreFoundation.framework]"
)}}
Then I transferred NSColor to NSArray - but the error was the same.
I want data save in Core Data, please help me ♡.
So I am creating an ObjC framework which has mix of ObjC and Swift code: UtilitiesFramework.
Here is my StringUtilities class in Swift:
@objc
public class StringUtilities: NSObject { }
I am accessing StringUtilities class in Utilities which is an ObjC class.
Here is Utilities.h which is returning StringUtilities and has a forward class declaration for same:
@class StringUtilities; // Forward Declaration
@interface Utilities: NSObject
- (StringUtilities *)stringUtilities;
@end
Here is Utilities.m which imports generated swift header file:
#import <UtilitiesFramework/UtilitiesFramework-Swift.h> // This should provide concrete implementation of StringUtilities
@implementation Utilities
- (StringUtilities *)stringUtilities {
return [StringUtilities new];
}
@end
I am exposing Utilites.h file to Swift through module.modulemap:
module PrivateObjC {
header "Utilities.h"
}
I have set the import path accurately in build settings as:
$(SRCROOT)/$(PRODUCT_NAME)
Now when I try to access Utilities class in some other swift class it just compiles fine:
import PrivateObjC
class SomeOperations {
func doSomething() {
_ = Utilities() // This compiles fine
}
However when I try to access the StringUtilities through its method, it gives compilation error:
import PrivateObjC
class SomeOperations {
func doSomething() {
_ = Utilities().stringUtilities() // This gives compilation error
}
Here are the errors:
value of type Utilities has no member stringUtilities: _ = Utilities().stringUtilities()
note: method stringUtilities not imported
- (StringUtilities *)stringUtilities
^
note: return type not imported
- (StringUtilities *)stringUtilities
^
note: interface StringUtilities is incomplete
- (StringUtilities *)stringUtilities
^
note: interface StringUtilites forward declared here
@class StringUtilities
I thought this scenario is fixed as part of proposal:
# 0384-importing-forward-declared-objc-interfaces-and-protocols.md
However it is not working for me. May be it is due to it being approved as part of Swift 5.9, whereas in my machine 5.8.1 is used or am I missing anything else over here?
Update: I installed Xcode 15 and double checked the swift version which is 5.9, however I am still getting the error. Any idea why it is not working for a framework target?
Does anyone have a simple example for a scriptable App in Swift in Xcode for macOS? I mean one that exposes objects and functions to applescript?
I've checked all examples that I could find. But for me they get me confused about whether they are accessing the actual and already existing instance of a class or whether they are creating an instance with AppleScript, or just using the class definition to call some function. Also the way they are defined in the .sdef file does not help. It would be great if someone had a really simple example, stripped down to bare minimum that 1) defines a class with a single function, 2) creates an instance of the class inside appDelegate and then 3) the function of the specific instance is called using appleScript. 4) It would be great if the function could do something in the GUI, such as change a text of a Label.
I have the following in my .zshrc:
export MY_LIBRARY_DIR=~/bin
In Xcode I can set header/lib search path using something like $(MY_LIBRARY_DIR)/abc.
This works fine in my daily used user account. But today I found that this technique does not work in a test user account (for testing purpose only).
I even reboot my machine but still can't get it working.
Am I missing something very obvious???
BTW, I am using Xcode 14.2 and 14.3.1.
I'm currently developing a native plugin for a Capcitor app. I have very little experience with native iOS development, Swift and Obj-C.
I use a framework (FunSDK) which is written in C++.
I call this in an Objective-C++ wrapper.
As described here: https://medium.com/@cecilia.humlelu/set-up-c-library-dependencies-in-swift-projects-5dc2ccd2ddaf
The wrapper is then available in Swift via the bridging header.
This works so far, I can call the functions from the framework and they are executed correctly.
However, the functions of the framework are executed asynchronously. When a result is obtained, the “OnFunSDKResult” method is always executed.
During this step I get an EXC_BAD_ACCESS error while debugging. Then I ticked “Zombie objects” under the diagnostics settings. This causes execution to stop with an EXC_BREAKPOINT.
As I understand it, after executing the iniXMSDK method, the FunSDKWrapper class is cleared from memory before executing the "OnFunSDKResult" method?
I have also already integrated a completionHandler, which is only called in the "OnFunSDKResult" method so that data is transferred to the Swift class. However, that doesn't help either.
I have no idea how to proceed.
I hope somebody can help me.
If you need any more information, I would be happy to provide it.
The FunSDKWrapper.mm
//
// FunSDKWrapper.m
// App
//
// Created by Sysprobs on 12/8/23.
//
#import "FunSDKWrapper.h"
#import "FunSDK/FunSDK.h"
#import <XMNetInterface/Reachability.h>
@implementation FunSDKWrapper
-(NSString *)iniXMSDK:(int)test completion:(void (^)(int result))completionHandler{
self.initCompletionHandler = completionHandler;
self.msgHandle = FUN_RegWnd((__bridge void *)self);
FUN_Init();
Fun_LogInit(self.msgHandle, "", 0, "", LOG_UI_MSG);
FUN_XMCloundPlatformInit("***", "***", "***", 1);
FUN_InitNetSDK();
FUN_SetFunStrAttr(EFUN_ATTR_SAVE_LOGIN_USER_INFO,SZSTR([self GetDocumentPathWith:@"UserInfo.db"]));
FUN_SetFunStrAttr(EFUN_ATTR_USER_PWD_DB, SZSTR([self GetDocumentPathWith:@"password.txt"]));
FUN_SetFunStrAttr(EFUN_ATTR_UPDATE_FILE_PATH,SZSTR([self GetDocumentPathWith:@""]));
FUN_SetFunStrAttr(EFUN_ATTR_TEMP_FILES_PATH,SZSTR([self GetDocumentPathWith:@""]));
FUN_SetFunIntAttr(EFUN_ATTR_AUTO_DL_UPGRADE, 0);
FUN_SetFunStrAttr(EFUN_ATTR_CONFIG_PATH,SZSTR([self GetDocumentPathWith:@"APPConfigs"]));
FUN_SetFunIntAttr(EFUN_ATTR_SUP_RPS_VIDEO_DEFAULT, 1);
FUN_SetFunIntAttr(EFUN_ATTR_SET_NET_TYPE, [self getNetworkType]);
FUN_SysInit("arsp.xmeye.net;arsp1.xmeye.net;arsp2.xmeye.net", 15010);
FUN_InitNetSDK();
FUN_SysGetDevList(self.msgHandle, SZSTR(@"xxxx") , SZSTR(@"xxxx"),0);
return @"test";
}
- (void)searchLanDevices {
FUN_DevSearchDevice(self.msgHandle, 4000, 0);
}
// NSDocument/fileName
- (NSString *)GetDocumentPathWith:(NSString *) fileName {
NSString* path = [self documentsPath];
if (fileName != nil) {
path = [path stringByAppendingString:@"/"];
path = [path stringByAppendingString:fileName];
}
return path;
}
//NSDocument
- (NSString *)documentsPath {
NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [pathArray lastObject];
return path;
}
-(int)getNetworkType {
Reachability*reach=[Reachability reachabilityWithHostName:@"www.apple.com"];
//判断当前的网络状态
switch([reach currentReachabilityStatus]){
case ReachableViaWiFi:
return 1;
case ReachableViaWWAN:
return 2;
default:
return 0;
break;
}
}
- (void)OnFunSDKResult:(NSNumber *) pParam {
NSInteger nAddr = [pParam integerValue];
MsgContent *msg = (MsgContent *)nAddr;
switch (msg->id) {
case EMSG_SYS_GET_DEV_INFO_BY_USER:{
self.initCompletionHandler(1);
if (msg->param1 < 0){
//fehler
NSLog(@"Fehler beim XMCloud login");
}else{
char devJson[750*500];
FUN_GetFunStrAttr(EFUN_ATTR_GET_USER_ACCOUNT_DATA_INFO, devJson, 750*500);
NSLog(@"Geraeteliste: = %s",devJson);
}
}
break;
}
}
@end
The Swift Class
import Foundation
import Capacitor
/**
* Please read the Capacitor iOS Plugin Development Guide
* here: https://capacitorjs.com/docs/plugins/ios
*/
@objc(xmsdkPlugin)
public class xmsdkPlugin: CAPPlugin {
private let implementation = xmsdk()
@objc func echo(_ call: CAPPluginCall) {
let value = call.getString("value") ?? ""
call.resolve([
"value": implementation.echo(value)
])
}
@objc func initXMSDK(_ call: CAPPluginCall) {
//let devId = call.getString("devId") ?? ""
let wrapper = FunSDKWrapper();
let resp = wrapper.iniXMSDK(1, completion: {(result) -> Void in
NSLog("Completion von iniXMSDK")
});
call.resolve([
"status": resp
])
}
}
Errorlog with EXC_BREAKPOINT:
hi, I am using the openpty function in my code to run an interactive command, for example, "hdiutil convert -format UDRO /tmp/myFileName.sparsebundle -o ./test". The file myFileName.sparsebundle is an encrypted disk with a password. When running this command, it triggers the security server and a password input dialog box pops up. I don't want this dialog box to appear, and I want to provide the password through the fd_master returned by openpty. How can I achieve this?
I created one application using Websocket when TLS version was 1.2 connection establishment working fine but when server team update TLS1.2 to TLS1.3 due to security enhancement in my project i am getting SSL Handshake fails with code 9836. and NSOSStatusErrorDomain with code 9836.
here is my info.plist
NSAppTransportSecurity NSAllowsArbitraryLoads NSExceptionDomains myserver.com NSIncludesSubdomains NSExceptionMinimumTLSVersion TLSv1.3
So my query here is that even if we specify TLSv1.3 for myserver.com as: NSExceptionMinimumTLSVersion TLSv1.3
we want to restrict only to TLS1.3, even if my request fails, how to achieve this?
I received a crash dump from an ARM64 Mac. I see my code here but from what I can tell it looks like this "crash" occurred during cleanup/quit.
One thing that caught my eye here is the symbol __A_WATCHDOG_TIMEOUT_HAS_OCCURRED__ that shows up just before exit. Does this mean the watchdog timeout initiated exit? Can I determine why?
Crashed Thread: 13
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000019c61427c
Termination Reason: Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process: exc handler [60432]
...
Thread 13 Crashed:
0 FrontBoardServices 0x000000019c61427c -[FBSMainRunLoopSerialQueue assertBarrierOnQueue] + 144 (FBSSerialQueue.m:264)
1 FrontBoardServices 0x000000019c5ca91c -[FBSScene detachLayer:] + 44 (FBSScene.m:222)
2 UIKitCore 0x00000001b59c0538 -[_UIFBSSceneSubstrate detachContext:] + 92 (_UIFBSSceneSubstrate.m:74)
3 UIKitCore 0x00000001b5569168 __UIContextBinderDetachContext + 240 (_UIContextBinder.m:367)
4 UIKitCore 0x00000001b5569014 -[_UIContextBinder detachBindable:] + 192 (_UIContextBinder.m:149)
5 UIKitCore 0x00000001b5568ed0 -[UIWindowScene _windowUpdatedVisibility:] + 84 (UIWindowScene.m:1162)
6 UIKitCore 0x00000001b5568d38 -[UIWindow _updateLayerOrderingAndSetLayerHidden:actionBlock:] + 192 (UIWindow.m:2330)
7 UIKitCore 0x00000001b55b9ae8 -[UIWindow _setHidden:forced:] + 104 (UIWindow.m:2556)
8 SDL2 0x00000001026ccb6c 0x102660000 + 445292
9 SDL2 0x0000000102713828 SDL_DestroyWindow + 164
10 My App 0x0000000102073890 cleanup + 60 (init.c:129)
11 libsystem_c.dylib 0x0000000186ddcfa8 __cxa_finalize_ranges + 492 (atexit.c:292)
12 libsystem_c.dylib 0x0000000186ddcd20 exit + 44 (exit.c:78)
13 UIKitMacHelper 0x000000019fbb60ec __A_WATCHDOG_TIMEOUT_HAS_OCCURRED__ + 192 (UINSLifecycleWatchdog.m:35)
14 UIKitMacHelper 0x000000019fbb487c __60-[UINSLifecycleWatchdog initWithStateIdentifier:andTimeout:]_block_invoke + 1160 (UINSLifecycleWatchdog.m:77)
15 UIKitMacHelper 0x000000019fbb5828 run_watchdog_thread + 276 (UINSLifecycleWatchdog.m:305)
16 libsystem_pthread.dylib 0x0000000186f1d034 _pthread_start + 136 (pthread.c:904)
17 libsystem_pthread.dylib 0x0000000186f17e3c thread_start + 8 (:-1)
I want to read metadata of image files such as copyright, author etc.
I did a web search and the closest thing is CGImageSourceCopyPropertiesAtIndex:
- (void)tableViewSelectionDidChange:(NSNotification *)notif {
NSDictionary* metadata = [[NSDictionary alloc] init];
//get selected item
NSString* rowData = [fileList objectAtIndex:[tblFileList selectedRow]];
//set path to file selected
NSString* filePath = [NSString stringWithFormat:@"%@/%@", objPath, rowData];
//declare a file manager
NSFileManager* fileManager = [[NSFileManager alloc] init];
//check to see if the file exists
if ([fileManager fileExistsAtPath:filePath] == YES) {
//escape all the garbage in the string
NSString *percentEscapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)filePath, NULL, NULL, kCFStringEncodingUTF8);
//convert path to NSURL
NSURL* filePathURL = [[NSURL alloc] initFileURLWithPath:percentEscapedString];
NSError* error;
NSLog(@"%@", [filePathURL checkResourceIsReachableAndReturnError:error]);
//declare a cg source reference
CGImageSourceRef sourceRef;
//set the cg source references to the image by passign its url path
sourceRef = CGImageSourceCreateWithURL((CFURLRef)filePathURL, NULL);
//set a dictionary with the image metadata from the source reference
metadata = (NSDictionary *)CGImageSourceCopyPropertiesAtIndex(sourceRef,0,NULL);
NSLog(@"%@", metadata);
[filePathURL release];
} else {
[self showAlert:@"I cannot find this file."];
}
[fileManager release];
}
Is there any better or easy approach than this?
Hi there,
Currently, I'm assigned to do the task that allow user can sign their digital signature on iPhone. I've researched for a week and so far, I'm lost on my way.
I want to ask your all experience in working the similar task. My demand is:
Allow users upload PDF document
Then, allow users sign their digital signature
Please give me a logic, step and how it works programmatically to research, in order to do this task. Thank you all <3