2011年5月29日 星期日

objective-c SEL 跟 NSString 轉換!!


SEL 轉 NSString
NSString *msg = [NSString stringWithFormat:@"%@ doesn't exist!",NSStringFromSelector(selector)];
常常用來記錄一些錯誤!!;
//-----------------------------------------------
NSString 轉 SEL
NSString *actionName = [NSString stringWithFormat:@"%@:",action.m_Action];
SEL actionFunc = NSSelectorFromString(actionName);
then you can do like:
[self performSelector:actionFunc];
常常用來 在runtime 動態產生 SEL


測式頁面

test