Objc中的对象归档

#import <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSKeyedArchiver.h>

@interface Foo : NSObject<NSCoding> {
    NSString *strVal;
    int intVal;
    float floatVal;
}
@property(copy, nonatomic)NSString *strVal;
@property int intVal;
@property float floatVal;
@end


@implementation Foo
@synthesize strVal, intVal, floatVal;

-(void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:strVal forKey:@"FoostrVal"];
    [encoder encodeInt:intVal forKey:@"FoointVal"];
    [encoder encodeFloat:floatVal forKey:@"FoofloatVal"];
}

-(id)initWithCoder:(NSCoder *)decoder {
    strVal = [decoder decodeObjectForKey:@"FoostrVal"];
    intVal = [decoder decodeIntForKey:@"FoointVal"];
    floatVal = [decoder decodeFloatForKey:@"FoofloatVal"];
    return self;
}
@end

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        Foo *myFoo1 = [[Foo alloc]init];
        Foo *myFoo2;
        [myFoo1 setStrVal:@"This is the string"];
        [myFoo1 setIntVal:12345];
        [myFoo1 setFloatVal:98.6];
        [NSKeyedArchiver archiveRootObject:myFoo1 toFile:@"foo.arch"];
        myFoo2 = [NSKeyedUnarchiver unarchiveObjectWithFile:@"foo.arch"];
        NSLog(@"%@ %i %g\n", [myFoo2 strVal], [myFoo2 intVal], [myFoo2 floatVal]);
    }
    return 0;
}

获取 Android 源码包中的资源

 String path = "com/example/testres/1.jpg";
        InputStream is = getClassLoader().getResourceAsStream(path);
        Drawable background = Drawable.createFromStream(is, null);

ObjectiveC Property

Alt none

ref: Cocoa Programming for Mac OS X p94

XLIFF 在 Android 中的简单应用

XLIFF(XML Localization Interchange File Format): XML本地化数据交换格式。

string.xml

<resources xmlns:xliff="urn.oasis:names:tc:xliff:document:1.2">

    <string name="person"><xliff:g id="name">%1$10s</xliff:g> <xliff:g id="age">%2$s</xliff:g></string>

</resources>

JAVA

String person = getString(R.string.person, "lnmcc", 90);

参数格式说明

id: 属性名 %n$m[s,d,f]: n参数索引;m对齐方式或数据精度;[s,d,f]接受的数据类型

Android Framework 配置需要默认编译APK

build/target/product/core.mk