[objective-c]NSDateから文字列生成

NSDateから文字列生成

-(NSString*) getDatetimeFromDate:(NSDate*)date
{
    NSDateFormatter* form = [[NSDateFormatter alloc] init];
    NSCalendar* cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    [form setCalendar: cal];
    [form setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString* str = [form stringFromDate:date];
    return str;
}
NSString*dateString=[self getDatetimeFromDate:[NSDate date]];

[objective-c]EGODatabase #9 カラムの型一覧取得

カラムの型一覧取得

-(EGODatabase*)getDB
{
    EGODatabase* database = [EGODatabase databaseWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/database.db"]];
    return database;
}
-(NSDictionary*)getColumnTypesByTableName:(NSString*)tableName
{
    EGODatabase*db=[self getDB];
    NSString*sql=[NSString stringWithFormat:@"pragma table_info(%@)",tableName];
    EGODatabaseResult*result=[db executeQuery:sql];
    NSMutableDictionary*dic=[NSMutableDictionary dictionary];
    for (EGODatabaseRow*row in result) {
        [dic setObject:[row stringForColumn:@"type"] forKey:[row stringForColumn:@"name"]];
    }
    return dic;
}

[objective-c]EGODatabase #8 カラム名一覧取得

カラム名一覧取得

-(NSArray*)getColumnNamesByTableName:(NSString*)tableName{
    EGODatabase*db=[self getDB];
    NSString*sql=[NSString stringWithFormat:@"pragma table_info(%@)",tableName];
    EGODatabaseResult*result=[db executeQuery:sql];
    NSMutableArray*list=[NSMutableArray arrayWithCapacity:[result count]];
    for (EGODatabaseRow*row in result) {
        [list addObject:[row stringForColumn:@"name"]];
    }
    return [NSArray arrayWithArray:list];
}

[objective-c]EGODatabase #7 テーブル一覧取得

テーブル一覧取得

-(NSArray*)getTableNameList{
    EGODatabase*db=[self getDB];
    NSString*sql=@"select name from sqlite_master where type = 'table' order by name";
    EGODatabaseResult*result=[db executeQuery:sql];
    NSMutableArray*list=[NSMutableArray arrayWithCapacity:[result count]];
    for (EGODatabaseRow*row in result) {
        [list addObject:[row stringForColumn:@"name"]];
    }
    return [NSArray arrayWithArray:list];
}
-(EGODatabase*)getDB{
    EGODatabase* database = [EGODatabase databaseWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/database.db"]];
    return database;
}
-(BOOL)isExistTableByName:(NSString*)tableName{
    NSArray*tables=[self getTableNameList];
    return [tables containsObject:tableName];
}

[objective-c]ファイル存在確認

ファイル存在確認

//Documentsフォルダ内を確認
-(BOOL)isExistFile:(NSString*)fileName{
    NSString* path=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    path=[path stringByAppendingPathComponent:fileName];
    return [[NSFileManager defaultManager] fileExistsAtPath:path];
}
//fullパスで確認
-(BOOL)isExistFileByFullPath:(NSString*)path{
    return [[NSFileManager defaultManager] fileExistsAtPath:path];
}

[JavaScript]Fireworksコマンド - 選択したパスの塗りつぶし色を取得

選択したパスの塗りつぶし色を取得

var dom = fw.getDocumentDOM();
var r=0;
var le = fw.selection.length;
var d=new Array();
var str="";
var cols=[];
for (var m=0;m<le;m++){
	if(fw.selection[m]["pathAttributes"] && fw.selection[m]["pathAttributes"]["fillColor"]){
		var col=fw.selection[m].pathAttributes.fillColor;
		cols.push( {col:col, sort:getSortNum(col)} );
	}
}
cols=cols.sort(sortCol);
for(var m=0;m<cols.length;m++){
	if(m>0)str+=',';
	str+='"'+cols[m].col+'"';
}

var w=prompt('',str);

if(!w){
	cols=cols.reverse();
	str="";
	for(var m=0;m<cols.length;m++){
		if(m>0)str+=',';
		str+='"'+cols[m].col+'"';
	}

	var w=prompt('',str);
}
function sortCol(a,b){
	if(a.sort > b.sort)return 1;
	if(a.sort < b.sort)return -1;
	return 0;
}
function getSortNum(value){
	value=value.replace('#','');
	return Number('0x'+value);
}
function showInfo(obj){
	var str="";
	str+=obj;
	for(var key in obj){
		str+="\n";
		str+=key+" : "+obj[key];
	}
	alert(str);
}