AppList: Difference between revisions

From iPhone Development Wiki
No edit summary
Line 13: Line 13:
The common way to use AppList is via its [[PreferenceLoader]] (preferences) integration, by putting entries in a PreferenceLoader plist: [https://github.com/rpetrich/AppList/blob/master/sample/layout/Library/PreferenceLoader/Preferences/AppListSample.plist AppListSample.plist].
The common way to use AppList is via its [[PreferenceLoader]] (preferences) integration, by putting entries in a PreferenceLoader plist: [https://github.com/rpetrich/AppList/blob/master/sample/layout/Library/PreferenceLoader/Preferences/AppListSample.plist AppListSample.plist].


To access the list of applications use the following:
<source lang=objc>
<source lang=objc>
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile: plistpath];
NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile: plistpath];
</source>
</source>


List of enabled apps:
Then to filter by enabled apps:


<source lang=objc>
<source lang=objc>
[[plistDict objectForKey:@"enable"] isEqualToString: @"YES"]  
[[plistDict objectForKey:@"enable"] isEqualToString: @"YES"]  
</source>
</source>
As seen in https://github.com/iceNuts/DisableNC-Switch


=== Without PreferenceLoader ===
=== Without PreferenceLoader ===

Revision as of 20:52, 3 March 2014

AppList
Cydia Package
Developer Ryan Petrich
Package ID applist
Latest Version 1.5.7


AppList is a library for fetching app information. As described on its package page in Cydia: "Allows developers to query the list of installed apps and provide a preferences pane based on that information. Exports displayIdentifier, displayName, icon and smallIcon via a remote messaging center so that it's easy to write a prefs pane that presents a list of apps."

Usage

With PreferenceLoader

The common way to use AppList is via its PreferenceLoader (preferences) integration, by putting entries in a PreferenceLoader plist: AppListSample.plist.

To access the list of applications use the following:

NSMutableDictionary *plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile: plistpath];

Then to filter by enabled apps:

[[plistDict objectForKey:@"enable"] isEqualToString: @"YES"]

As seen in https://github.com/iceNuts/DisableNC-Switch

Without PreferenceLoader

To get an array of applications and their display identifiers, do the following:

ALApplicationList *apps = [ALApplicationList sharedApplicationList]; //list all the apps

NSArray *displayIdentifiers = [[apps.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
	    return [[apps.applications objectForKey:obj1] caseInsensitiveCompare:[apps.applications objectForKey:obj2]];}]; //sort the apps by display name
[displayIdentifiers retain]; //make sure it doesn't disappear when you actually need to use it, if you only use it once, release it

This gives you a list of all the apps in alphabetical order by their display name.

To get the display identifier and icon for a specific app at index {X} do the following:

NSString *displayIdentifier = [displayIdentifiers objectAtIndex:{X}];
UIImage *icon = [apps iconOfSize:{size here - see enums} forDisplayIdentifier:displayIdentifier];
enum {
	ALApplicationIconSizeSmall = 29,
	ALApplicationIconSizeLarge = 59
};

External links