Cephei

From iPhone Development Wiki
Jump to: navigation, search
Cephei
Cydia Package
Developer HASHBANG
Package ID Cephei
Latest Version 1.16

Cephei is a framework that provides various convenience methods.

How to use this framework

Headers are available from Cephei’s Github project and the framework can be found at /Library/Frameworks/Cephei.framework on a device where Cephei is installed. Theos and Dragon both include the headers so you don’t have to worry about installing them!

Include directive

#import <Cephei/Cephei.h>

Makefile

Add to your Makefile:

Cephei to the XXX_EXTRA_FRAMEWORKS variable.

Dragon

Add to your DragonMake file:

Cephei to the frameworks variable in any module.

Packaging

Add to your package’s control file:

ws.hbang.common to the Depends field

Getting a tweak’s preferences

The HBPreferences class allows for easy access to preferences. Note: Cephei does not allow you to access most Apple preferences (preferences that have their identifier starting with com.apple).

%ctor {
    // The identifier must be the preference identifier of the bundle wanted
    HBPreferences *preferences = [[HBPreferences alloc] initWithIdentifier:@"com.example.ExamaplePreference"];
    // Getting the value of a cell with the key of enabled
    BOOL enabled;
    // Returns the value set for the key, or default set in preferences if no value has been set. If no default, returns nil
    enabled = [preferences boolForKey:@"enabled"];
    // The register methods automatically update the variable that gets passed to them. If no preference has been set, the variable is set to the default passed
    [preferences registerBool:enabled default:YES forKey:@"enabled"];
}

In order to have the -registerObject:default:forKey methods to automatically update, a notification, set to the preference identifier with /ReloadPrefs appended, needs be posted.

<dict>
<!-- Interesting preference cell -->
    <key>PostNotification</key>
    <string>com.example.ExamaplePreference/ReloadPrefs</string>
</dict>

Converting hex color to UIColor

Cephei provides a method to easily convert CSS style hex color to UIColor.

UIColor *color = [UIColor hb_colorWithPropertyListValue:@"#ffa1aa"];

External links

Cephei’s source code

Cephei’s documentation