Custom Finder (folder) Image w/ Cocoa [duplicate] - objective-c

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Using Cocoa to create an icon for a folder
I'm trying to set a custom folder image, but only with cocoa, as dropbox:
But I realized that this isn't really simple.
Anyone with some solution/tip?

Use - (BOOL)setIcon:(NSImage *)image forFile:(NSString *)fullPath options:(NSWorkspaceIconCreationOptions)options method of NSWorkspace Class.

Related

How to use Objective-C category in Swift file [duplicate]

This question already has answers here:
How do I call Objective-C code from Swift?
(17 answers)
Closed 6 years ago.
I have an Objective-C project, there is a file named 'NSDictionary+Test', and a method named - (void)testDone:(TestBlock)block in the file. I add a swift file to the project , how can i use - (void)testDone:(TestBlock)block in my Swift file.
So firstly you have your Objective C proj and in it you have your category(in Obj C) and now you added a Swift file and want to use category method in Swift.
So now answer goes-
Firstly add your .swift file and mostly it asks for creating a bridging header. If it does not get created, follow the steps from this.
Add #import "NSDictionary+Test.h" before #endif.
Now you should be able to use the (void)testDone:(TestBlock)block as dictionary.testDone(block : TestBlock!).

How to create a category in Xcode 7.2? [duplicate]

This question already has answers here:
How do I create a category in Xcode 6 or higher?
(8 answers)
Closed 6 years ago.
How do I create a category to an existing Cocoa Touch Class for objective-c in Xcode 7.2? I've been looking for an hour but couldn't find anything helpful.
File > New > File…
iOS > Source
Objective-C File
Next
File Type: Category
Example:

Install font to system programmatically in Mac [duplicate]

This question already has answers here:
Embed font in a mac bundle
(2 answers)
Closed 7 years ago.
I know, if I want to use a font, that already exists in system, I can set it, for example, this way (1):
[[_someButton cell] setFont:[NSFont fontWithName:#"SomeAlreadyInstalledFontName" size:s]];
I also know, I can use a custom font from my project resources someway like that (2):
NSFont* someCustomFont = (NSFont*)[fontConverter fontFromBundle:#"SomeCustomFontName" withHeight:someHeight];
[[_someButton cell] setFont:someCustomFont(12)];
fontConverter is my class, that has a method with this signature:
- (CTFontRef) fontFromBundle : (NSString*) fontName withHeight : (CGFloat) height;
It works, however I want, instead of using method (2), install my custom font to system and work with it like (1).
So is it possible to do this: check, if custom font is installed in system, if no, then install it, when the application is launched/being installed?
File > Add Files to "Your Project Name"
then move your file to supporting files and be sure that you selected right target for your app and check that following paths:
Select your project from project navigator> Build Phases> Copy Bundle
Resources
if your font appears there it means you did everything correct. The last step is add your font to .plist file:
Select your info.plist add an array Fonts provided by application and
add your font in it as a string
It worked in my case and hope it will help you, too. For further information you may examine this: Adding custom fonts

Custom Actions for Custom URL Schemes Mac Objective-c [duplicate]

This question already has answers here:
How to handle with a default URL scheme
(5 answers)
Closed 9 years ago.
how can I make it so that if the URL is myapp://foo that it will preform an action and if it is myapp://bar it will preform a different action.
I've gotten this far with my other question here
Help is very much appreciated.
Once you have your URL scheme registered inside your application, you should be able to capture the URL used to open your application with something like this
- (void)handleURLEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent {
NSString *calledURL = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
NSLog(#"%#", calledURL);
// Split and do something with calledURL
}
Once you have that URL you should easily be able to split it and determine what you want to do.
There is another question on exactly this as well.

How to add .a C static library to Xcode and use it there? [duplicate]

This question already has answers here:
How can I "add existing frameworks" in Xcode 4?
(10 answers)
Closed 8 years ago.
I have a static C library compiled with arm7-gcc and i want to use it in my iOS project. i added it to project but i can't figure out how to use it.
After adding the library to the project and including the header in your application codeб there is a second step. That step is letting the Xcode project know where the header file/files is/are. You do this by editing the "User Header Search Paths" build setting with the path to the header files.