How to get the unique identifier of an application on IOS - objective-c

I would like to get the unique identifier of my application that is used as the file name in the IOS file system. How to do that ?

If you are talking about path to your app which contains uniq. identificator then you can extract this id from path of main bundle [[NSBundle mainBundle] bundlePath].

Related

UIDocumentPickerViewController initForExportingURLs asCopy creates zero length file on network volume

I'm using the following code snippet in a Mac Catalyst app to "export" (copy) a file from an URL to a user-selected URL:
UIDocumentPickerViewController* documentPicker = [[UIDocumentPickerViewController alloc] initForExportingURLs:#[ [[NSURL alloc] initFileURLWithPath:path] ] asCopy:YES];
This works as expected if a local folder is picked (the file in path is copied there). However, if a network folder is picked (in this case, SMB), a zero-length file is generated and no error is shown.
Does anyone know what might cause this?

getting info about mac OS X application programmatically

I'm looking for cocoa framework that acquires the following information for each application : vendor name, version and full application name.
Alternatively, I could use a file that contain this information ... I've tried to search it in /Application/(name).app/... but I couldn't find it in specific location that is the same for all applications.
It should be in the info.plist under CFBundleName
If you go into <application>/contents/info.plist you'll find it there
from the  documentation:
CFBundleName (String - iOS, OS X) identifies the short name of the
bundle. This name should be less than 16 characters long and be
suitable for displaying in the menu bar and the app’s Info window. You
can include this key in the InfoPlist.strings file of an appropriate
.lproj subdirectory to provide localized values for it. If you
localize this key, you should also include the key
CFBundleDisplayName.
here's an example code for acquiring version from Info.plist of a selected application:
string GetAppVersion(string app)
{
NSString *vlcFilePath = [NSString stringWithCString:app.c_str()];
NSDictionary* infoDict = [[NSBundle bundleWithPath:vlcFilePath] infoDictionary];
NSString* version = [infoDict objectForKey:#"CFBundleVersion"];
}
...
...
GetAppVersion("/Applications/Notes.app").c_str());

QCView fails to load quartz composition from file

I'm loading a Quartz composition from a file through this code:
// quartz is a QCView in the XIB file
QCComposition *qc = [QCComposition compositionWithFile:#"res/wdq.qtz"];
//NSLog(#"input keys %#",[qc inputKeys]);
//NSLog(#"copyright %#",[[qc attributes] valueForKey:QCCompositionAttributeCopyrightKey]);
[quartz loadComposition:qc];
and I get the error:
*** <QCComposition = 0x100258d80 | identifier = "(null)" | source = (null) | backing = "res/wdq.qtz": Failed loading composition
(file exists at location, loading the file from IB works inside IB but not when running the application)
Mac OS X Lion 10.7.3 | XCode 4.2 | Quartz Composer 4.5
The working directory might not be what you think it is. Try referencing it using an absolute path.
For example, assuming the qtz file is in your bundle's Resources folder:
NSString *path = [[NSBundle mainBundle] pathForResource:#"wdq" ofType:#"qtz" inDirectory:#"res"]]l
QCComposition *qc = [QCComposition compositionWithFile:path];

Cocoa creating temporary folders/directories for saving the files

Is it possible to create the temporary directories in cocoa application for saving the files temporarily.
As per the scenario I need to process some video files and those files firstly will be converted to thumbnails etc then whose files will be uploaded to server.
How this can be achieved?
The easiest way to get the temporary directory is to use NSTemporaryDirectory()
Edit
The above is no longer the approved method of locating the temporary directory. You should now use [NSFileManager URLForDirectory:inDomain:appropriateForURL:create:error:].
You can use NSTemporaryDirectory().
Returns the path of the temporary directory for the current user.
NSString* tempDir = NSTemporaryDirectory();
NSString* bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
tempDir = [tempDir stringByAppendingPathComponent:bundleIdentifier];

NSBundle bundleWithPath fails

I am trying to load a bundle using bundleWithPath but it always fails (returns nil)
I was wondering what can be teh reasons why it fails and what are the way to het more information about the error.
Thanks in advance for your help!
Regards,
The failure may have many reasons: the file doesn't exist, the file exist but not in the path you are looking for. It has some different extention. Or the file at your path is not in correct bundle format. That's all I can tell you without code.
From the documentation:
+bundleWithPath:
Returns an NSBundle object that corresponds to the specified directory.
+ (NSBundle *)bundleWithPath:(NSString *)fullPath
Return Value: The NSBundle object that corresponds to fullPath, or nil if fullPath does not identify an accessible bundle directory.