SlanissueToolkit.framework for iOS application, copyright ©2015 Slanissue.com.
- JSON en/decoding
- MD5 encryption
- Base64 en/decoding
- URL escape, unescape
- ...
- Aspect fit/fill size
- Reflection
- Transform 2D/3D
- GIF
- UUID
- Load UIImage with memory cache, format: PNG, JPEG, GIF
- Snapshot for UIView
- ...
- Page Scroll View
- Prism Scroll View
- Dock Scroll View
- Cover Flow View
Four directions, five states supported.
State Type | Description |
---|---|
Default | hidden |
Visible | pull to visible but cannot refresh yet |
Will Refresh | dragging distance enough to refresh, but still dragging |
Refreshing | refreshing after drag end |
Terminated | no more data |
- Swipe Table View Cell
- Segmented Button / ScrollView
- Waterfall View
- Particle View
- Blur View
- Karaoke Label
- QRCode Image
- ...
Array, stack, queue, single chain table for base data type: int, float, pointer, ...
Base array for CGPoint
// create a base array to store CGPoint data
ds_array * array = ds_array_create(sizeof(CGPoint), 256);
array->bk.assign = ds_assign_point_b;
// add points to data item
CGPoint point = CGPointMake(10, 20);
ds_array_add(array, (const ds_type *)&point);
// iterate through the array
NSInteger offset;
DS_FOR_EACH_ARRAY_ITEM(array, point, offset) {
S9Log("[%d]: %@", offset, NSStringFromCGPoint(point));
}
// destroy the array
ds_array_destroy(array);
NSString * file = @"aaaa.xml"; // saved in somewhere
S9XMLDocument * doc = [[S9XMLDocument alloc] initWithContentsOfPath:file];
// get the 1st child of root
S9XMLElement * element = [doc childAtIndex:0];
// get all grandson named "member" under the 2rd child named "meeting"
NSArray * members = [element elementsWithPath:@"meeting[1]/member"];
S9_FOR_EACH(members, element) {
S9Log(@"name: %@, text: [%@]", element.name, element.text);
}
[doc release];
Finite State Machine, which has finitely several states in it, only one of the states will be set as the current state in any time.
When the machine started up, we should build up all states and their own transitions for changing from self to another state, adding all states with their transitions one by one into the machine.
In each time period, the function tick
of machine will be call,
this function will enumerate all transtions of the current state,
try to evaluate each of them,
while one transtion's function evaluate
return YES,
then the machine will change to the new state by the transtion's target name.
When the machine stopped, it will run out from the current state, and here we should remove all states.
If current state changed, the delegate function fsm_machine_exit_state
will be call with the old state, after that,
fsm_machine_enter_state
will be call with the new state.
This mechanism can let you do something in the two opportune moments.
Memory Object File format, which allows you to save a dictionary object to a binary file, it's faster to load a tiny binary file and parse it, rather than an XML file.
Save an NSDictionary object to '.mof' file
NSString * dir = [[S9Client getInstance] temporaryDirectory];
NSString * file = [dir stringByAppendingPathComponent:@"zzz.mof"];
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
[dict setObject:@"moKy" forKey:@"name"];
MOFTransformer * writer = [[MOFTransformer alloc] initWithObject:dict];
[writer saveToFile:file];
[writer release];
or just call
MOFSave(dict, file);
Load a '.mof' file to an NSDictionary object
NSString * dir = [[S9Client getInstance] temporaryDirectory];
NSString * file = [dir stringByAppendingPathComponent:@"zzz.mof"];
MOFReader * reader = [[MOFReader alloc] initWithFile:file];
NSObject * root = [reader root];
[reader autorelease];
NSDictionary * dict = (NSDictionary *)root;
or just call
NSDictionary * dict = MOFLoad(file)
You can download language packs from remote, and save them in the caches directory with 'xxx.lproj' sub-directories.
After loaded them in your app, use S9LocalizedString
to translate.
// load language packs
NSString * dir = [[S9Client getInstance] cachesDirectory];
S9TranslatorScanLanguagePacks(dir);
// translate 'key' to a string
NSString * string = S9LocalizedString(@"key", @"comment");
The Four Arithmetic Operations
NSString * string = @"(2 + 2) * 2 - 2 / 2";
CGFloat result = CGFloatFromString(string);
S9Log(@"%@ = %f", string, result);
Actions:
- CallFunc
- CallBlock
- DelayTime
- Repeat(Forever)
- Sequence
- Spawn
- ...
-- by moKy @ Nov. 4, 2015