[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);
}

[CakePHP 2.x]テーブルのカラム名を取得

テーブルのカラム名を取得

$this->Model->getColumnTypes();

Controller

$columnTypes=$this->SystemTest->getColumnTypes();
$columnNames=array_keys($columnTypes);
$this->set('columnTypes', $columnTypes);
$this->set('columnNames', $columnNames);

View

columnTypes<br/>
<?php
$tmp=var_export($columnTypes,true);
echo str_replace("\n", "<br/>", $tmp);
?>
<br/><br/>
columnNames<br/>
<?php
$tmp=var_export($columnNames,true);
echo str_replace("\n", "<br/>", $tmp);
?>

Sample

[objective-c]UIButtonのラベルを複数行にする

UIButtonのラベルを複数行にする

testbutton.layer.borderWidth=1.0;
[testbutton setTitle:@"あいうえお\nかきくけこ" forState:UIControlStateNormal];
UILabel*innerLabel= testbutton.titleLabel;
innerLabel.numberOfLines=0;
innerLabel.frame=CGRectMake(0, 0, testbutton.frame.size.width, testbutton.frame.size.height);