Multi Value Setting (Settings.bundle) issue - objective-c

I just can't get Multi Value settings to work in my Ipad app.
This is my plist code for the multi value:
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>DefaultValue</key>
<string>0</string>
<key>Values</key>
<array>
<string>0</string>
<string>1</string>
<string>2</string>
</array>
<key>Title</key>
<string>Project</string>
<key>Key</key>
<string>project</string>
</dict>
I already tried everything, reset the iPad simulator, added other settings... and multi values keep on not showing in the settings. Am i missing something?

Solved this by defining the array of "Titles". It won't show the setting without it.

Related

NSUserDefaults objectIsForcedForKey with a nested dictionary

Currently I am using [[NSUserDefaults standardDefaults] objectIsForcedForKey: #"TestKey"]; to verify whether the key is managed or not.
This works great for a plist that would have each key on the list
<plist version="1.0">
<dict>
<key>Test</key>
<integer>1</integer>
</dict>
</plist>
but when I use nested dictionaries - the function can't seem to see that the object is being managed
<plist version="1.0">
<dict>
<key>TestKey1</key>
<integer>1</integer>
<dict>
<key>Dictionary2</key>
<dict>
<key>TestKey3</key>
<string>testkey3_value</string>
</dict>
</dict>
</dict>
</plist>
When I attempt to do something like [[NSUserDefaults standardDefaults] objectIsForcedForKey: #"TestKey3"]; It doesn't seem to realize that it is being managed
Your defaults domain does not include a key named "TestKey3". The dictionary containing that key is one of your own, and is not managed by NSUserDefaults. Therefore, NSUserDefaults's APIs will not be able to see '"TestKey3"`.

What plist settings should I use to share documents in iOS8

I'm trying to share a document using SLComposeServiceViewController in iOS, the document I'm testing this out with is a pdf (though I need the ability to share any file).
I send my PDF to Mail on the iPhone, press and hold on the attachment, but my icon never shows.
I have image, URL and Text share working fine, I just can't seem to get any type of document to work.
I'm assuming NSExtensionActivationSupportsAttachmentsWithMaxCount and/or NSExtensionActivationSupportsFileWithMaxCount need to be set, but I have no idea what the difference is between them.
This is my plist at the moment...
Can anyone help?
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>10</integer>
<key>NSExtensionActivationSupportsAttachmentsWithMinCount</key>
<integer>0</integer>
<key>NSExtensionActivationSupportsAttachmentsWithMaxCount</key>
<integer>20</integer>
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>0</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsVideoWithMaxCount</key>
<integer>0</integer>
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
<integer>0</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
These are predicates and all of them have to be satisfied for your extension to be shown. You probably only need NSExtensionActivationSupportsAttachmentsWithMinCount like this:
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsAttachmentsWithMinCount</key>
<integer>1</integer>
</dict>
<key>NSExtensionPointName</key>
<string>com.apple.share-services</string>
<key>NSExtensionPointVersion</key>
<string>1.0</string>
</dict>
Test using just TRUEPREDICATE to make sure the predicates are really the cause of the problem.
One more thing: share extensions are not enabled by default, so make sure you check the More [...] button at the end of the list of share targets.
You can get files from Mail (or similar) and Dropbox (Box, iCloud or similar) with this code in your extension info.plist
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>

When registering my application with Growl, how can I define what notification style to use in the .growlRegDict file?

I would like to force growl to use the Bezel style notification for all notifications in my application.
Considering a typical .growlRegDict looks something like the example below, is there a key/value that I can define in my application's .growlRegDict file that will set the default style for my application to the Bezel style.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList- 1.0.dtd">
<plist version="1.0">
<dict>
<key>TicketVersion</key>
<integer>1</integer>
<key>AllNotifications</key>
<array>
<string>MyNotification</string>
</array>
<key>DefaultNotifications</key>
<array>
<string>MyNotification</string>
</array>
</dict>
</plist>
After posting to the Growl Google group, I've found out that defining the alert style for your own application is not possible. Whatever the end user has configured as their preferred alert style overall or for each particular application is the style that will be used.

NSPerformService "Tweet" with an Image (Twitter.app)

Is there anyway to NSPerformService(#"Tweet", [NSPasteboard generalPasteboard]); with an image? I know that simply text is possible, but i don't know about the image.If yes, example code would be nice.
Thank you.
PS: for those who don't know, this is only possible if the user has the Twitter.app installed.
The types that you can send to a service depends upon the types that the registered application has declared in its Info.plist. For Twitter.app, this looks like:
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Tweet</string>
</dict>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
</array>
Unfortunately, this means that you will have to transform the image into a string before it will be accepted by the service.

How to define a Uniform Type Identifier in a plist file?

My application uses the following NSApplicationDelegate function.
- (void)application:(NSApplication*)sender openFiles:(NSArray*)filenames;
I want to use this function to enable the user to drag and drop image files onto the application icon in the dock.
How do I have to define certain file types in my plist file to restrict them to be images? I found out the structure has to look something like this.
// plist file contents taken from Preview.app
[...]
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFile</key>
<string>jpeg.icns</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSIsAppleDefaultForType</key>
<true/>
<key>LSItemContentTypes</key>
<array>
<string>public.jpeg</string>
</array>
<key>NSDocumentClass</key>
<string>PVDocument</string>
</dict>
</array>
I added it to the plist file but it does not work. A popup window shows the following error message.
The document "test.jpg" could not be opened. MyApp cannot open files
in the "JPEG image" format.
Further, I read in the documentation that there is public.image which would be what I want to define.
Meanwhile, I found out that the plist file only contains the key CFBundleDocumentTypes if I create a Cocoa Application with the option "Create document-based application.". Can you please clarify what dependencies exist for the option?
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>png</string>
<string>jpg</string>
... add as many types as you need
</array>
... other keys
</dict>
</array>
Update: The CFBundleDocumentTypes key is deprecated in Mac OS X v10.5. The new key LSItemContentTypes should be used instead. The items are UTI strings:
<key>LSItemContentTypes</key>
<array>
<string>public.png</string>
</array>
If your document types are common types, you could use UTI's
About UTI's