2012年5月31日 星期四

VBoxManage modifyhd Rails.vdi --resize 16384

VBoxManage modifyhd Rails.vdi --resize 16384

呢句command 用黎resize current virtual HD 仲要extend 個partition 同埋format 架 

2012年5月22日 星期二

iOSskills view hierarchy

//Recurive Message to find view hierarchy
-(void)findSuperView:(id)theView
{
    if ([theView superview] != nil) {
        NSLog(@"%@" , [[theView superview] class]);
        [self findSuperView:[theView superview]];
    }
   
}


UINavigatorController

終於到左NatvigationController

NatvigationController 會儲住一個stack 而呢個stack 既elements 係一堆viewControllers



















Push 推elements 入stack
Pop 拎elements 出stack
Top 最尾既element 都係第一個pop出黎
Base 最頭一個element


//push to next controller

    if (childController == nil) {
        childController = [[BIDDisclosureDetailController alloc]
                           initWithNibName:@"BIDDisclosureDetail" bundle:nil];
    }

//set childController properties
    childController.someMessage = detailMessage;
    childController.title = selectedMovie;
    [self.navigationController pushViewController:childController
                                         animated:YES];

[self.navigationController pushViewController:nextController animated:YES];

//pop (go back) to previous controller
[self.navigationController popViewControllerAnimated:YES];

//The view controllers currently on the navigation stack.
NSArray *allControllers = self.navigationController.viewControllers;

//retrieve last controller pushed into stack
UITableViewController *parent = [allControllers lastObject];

//reload data of parent tableview
[parent.tableView reloadData];

2012年5月21日 星期一

iOSskills selector

iOS 有個compiler driective 叫做@selector 用黎send message 比target

From Documentation
In Objective-C, selector has two meanings. It can be used to refer simply to the name of a method when it’s used in a source-code message to an object.

例如有個UIButton

UIBarButtonItem *moveButton = [[UIBarButtonItem alloc] initWithTitle:@"Move" style:UIBarButtonItemStyleBordered target:self action:@selector(toogleMove)];

target:self > 即係自己呢個class

toogleMove 係message name

- (IBAction)toogleMove{

...

}

如果想call既messge 有parameter 咁會變成 action:@selector(toogleMove:)

無parameter 就會唔好手多加 : 唔係compiler 搵唔到你想call message

P.S. 如果個message 有parameters

[friend performSelector:@selector(gossipAbout:) withObject:aNeighbor];



2012年5月20日 星期日

TableViewController

TableViewController


















呢個controller 好常用 可以做黎例曬data 更可以select一個之後push 下一個controller

有兩個protocoal 要conform
UITableViewDelegate
-(NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
設定每一row 既indentation . 如果每個row 多一個indentation return [indexPath row];


-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
設定每一個row 可唔可以被selected 例如第一個row 唔可以select

NSUInteger row = [indexPath row]
if(row== 0)
return nil;
return row;

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
設定每一個row既高度 return 70;



UITableViewDataSource
 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
一個section 入面有幾個row

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
每一個TableViewCell既setup
 

iOSSkills NSBundle NSURL

有陣時App 會用到一啲existing既file

例如有個static既file 叫做 fileName.ext


NSBundle *bundle = [NSBundle mainBundle]; //係app folder入面搵

NSURL  *someFileURL = [bundle URLForResource:@"fileName" withExtension:@"ext"];

如果用NSString:

NSString *path = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"ext"];

如果係plist

NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:someFileURL];

如果係wav

 SystemSoundID soundID;
    AudioServicesCreateSystemSoundID(
                                     (__bridge CFURLRef)someFileURL, &soundID);
    AudioServicesPlaySystemSound (soundID);

2012年5月19日 星期六

iOS skills setValue:forKey:

除左之前係針對UI elements 去學
仲有啲特別野係可以其他地方都用到

[self setValue:someValues forKey:keyNameOrVariable];
呢個message係一啲regular 既variable name好有用
例如你有五個NSArray

NSArray arr1 =...
NSArray arr2 =...
NSArray arr3 =...
NSArray arr4 =...
NSArray arr5 =... 

而每個NSArray 都要init 同比啲elements

for (int i = 1 ; i <=5 ; i++)
{
initialize..
initialize needed objects..
NSArray *tempArray = [[NSArray alloc] initWithObjects:obj1, obj2, obj3 , .. nil];f
NSString *arrayName = [[NSSting alloc] initWithFormat:@"arr%d" , i];

[self setValue:tempArray forKey:arrayName];
}
咁就set 曬全部array

P.S. From Beginning iOS 5 Development Apress Chapter 10



MultiView switching , TabBarController and PickerView

自從琴日interview見到自己既不足,今日“的”起心肝去認真學

手頭上都有五六本iOS 5 既dev ebook雖然又黎一年一度既WWDC

不過宜家黎講都叫最新 睇住黎學啦

我今日跟既本係Apress既 Beginning iOS 4 Development

http://www.apress.com/9781430236054

其實其他書都有講UINavigationController 但係呢本勝在 全面啲 多啲examaple

Chapter 9係UINavigationController 但係一開始作者又refer 到之前既example 咁無計啦 睇返前面

Chapter 7係點handle multiple views 由Window template 無XIB 開始
係appDelegate 連rootController
再係rootController加個ToolBar view同埋一個switching 既subview
唔難 但係清左concept

Chapter 8 TabBarController 同pickerView


呢個chapter 用一個tabBarController 去比user switch 五個唔同既view 每個view 都獨立既pickerView 由好簡單選擇日期(datePicker)
去到有個一個component 兩個獨立component
以至一個component depends on 一個component 最後一個簡單既老虎機


pickerView有datasource 同delegate 兩個protocol 要conform


data source:

-(NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView
個picker有幾多component 多數return 一個int

-(NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
一個component有幾多個row (options) return [self.array count];


delegate:

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
呢個message 係return 返相對應既row 字串 return [self.array objectAtIndex:row];

而component 可以用if 去拎 if(component == 0 ) return [self.someArray objectAtIndex:row];


-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
當user 係一個component 選擇左之後有咩要做 例如populate 另一個component

-(CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
呢個message 做少少interface 既改動 自訂每一個component既width (in pixel) return 90;









2012年5月18日 星期五

表現麻麻

今日表現其實幾差 答非所問
人地問左咩chenellges
點講都唔對題 係度遊花園 人地講左例子先知要講乜
人地問有咩常用既viewcontroller 問到一個UITableViewController 無 意會唔到UINavigationViewController 都係
orientation 又唔識答 只係話用default setting 點知iPad orientation 好重要 要識點處理
又問返cocos2d scene同layer既分別 我答得唔夠肯定
好彩iOS 5 有咩development advantage 仲答到...
縱合黎講 我覺得自己表現唔太好 又唔熟iOS5 ...黎緊啲日子要惡補一下

P.S. 頭先interview 仲唔知點解仲有個壞習慣 除左隻手錶係人地面前玩… 到底今日做緊乜?


2012年5月11日 星期五

回音

自從報左green tomato之後一直等消息 由三月尾等到四月 到宜家五月中 咁耐都仲未有真正既interview 到底佢地想點??

為免夜長夢多 報左兩個internship 。

舊公司老闆問我想唔想返去幫手 諗下仲可以 一諗起返到去執手尾(包括人地同自己) 學唔到太多野 而且又唔係自己想學  呢個係最後先會考慮

希望呢個暑假入間寫app既公司 睇下人地真正點去諗點去寫點推個app出市場 最好可以year 3 做埋part time 一黎錢 二黎儲經驗 始終覺得自己唔明成個app development 既流程 點設計 自己睇書又好似好散咁

仲有兩科考試 考埋真係搭尾班車搵intern

2012年5月10日 星期四

唔小心

今日返去cityu 溫 陪danny同昌哥 去水手食飯 點知janet打黎 同我講CV好多問題 好有心同我講之餘 過左deadline都比時間我改 有時我覺得我既運氣可能唔令到我中到抽獎六合彩 但係係呢啲影響人生影響前途既野上面 總係有人會出黎提我幫我 好感恩佢地對我既關愛同付出
Janet 提我一句 真實工作時好多野好急 但係一定要交之前自己把好個關 唔好比啲甩漏影響人地既印象
其實份之前都拎過比CAIO既人改過 但係可能果時改唔曬 自己又心急 求其交左就算
好多都係自己唔小心 又唔跟好啲 好彩好多時都有人提 唔係pk都似

2012年5月6日 星期日

unrar

如果你有堆rar file 你會點做?
對於我呢啲懶人唔會一個個unrar 費時失事
諗起ubuntu 有7z 既command line version
立即用黎試下


for f in *.rar; #先列出全部rar file
do mkdir "./stuff/$f" ;  #做一個同rar file同名既directory (注意directory name 唔可以同file 一樣名 所以用stuff 多一層隔住)
7z -o./stuff/$f e "$f"; #-o 係Set output directory -o同path無空格 e extract
done; #close loop



解曬出黎 每個rar有一個folder 儲住啲content 但係好衰唔衰佢有啲file corrupt左(unsupported method) 


刪曬啲output再黎
man unrar
但係unrar又無得set output directory .............


搞完一陣
係windows 裝7z
right click 全部rar











Extract to"*\" Done.

2012年5月3日 星期四

打機+溫書 =ineffective

本身諗住用電腦copy n paste lecture notes 呢整份notes 拎黎溫書 滿以為自可以控制慾望 反而被慾望控制 唉