IanMK2 Blog

처음 CentOS를 쓸때 ip를 확인하기위해 ifconfig를 쳐보니
어랏?

"command not found"

-_-?

어..어째서 이게 나오지 않는거지?!
했지만 /sbin안에 있었다. 
 
이걸 바로 명령어를 치면 되도록 수정해보자

#vi /etc/profile

맨 마지막에

export PATH="$PATH:/sbin"
를 추가하자 

재시작하거나

#source /etc/profile
로 설정을 다시 리로드

끗 
Posted by IanMK2
아파치와 텔넷을 위해 iptables를 수정하자

 
# vi /etc/sysconfig/iptables



# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT

# 텔넷 23  아파치 80
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 23 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT

-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
위와같이 라인을 삽입 후 저장
#/etc/init.d/iptables restart
ipatables 재시작
Posted by IanMK2
제가 오늘 얘기할것은 UICustomTableView사용시 많은 분들이 "빼먹는"것에 대한 것입니다.


UICustomTableViewCell은 아시다시피 단조로운 셀을 벗어나게 할 수 있는 소중하고 멋진 녀석이죠!

그런데 많은 분들이 커스템 셀의 경우 "큰" 실수를 하시는것을 많이 보았습니다.

일단 그 실수가 뭐인가 하기 전에 이 녀석을 한번 보죠!

dequeueReusableCellWithIdentifier


"어디서 많이봤는데.." 혹은, "앗 이 이녀석은.." 등 경험에 따라 눈에 익으신분도 있고 안 그러신분도 계실 것 입니다.

어디서봤을까요?

// Customize the appearance of table view cells.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    

    static NSString *CellIdentifier = @"Cell";

    

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[[UITableViewCell allocinitWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

    }

    

    // Configure the cell...

    

    return cell;

}



바로 셀을 리턴하는 함수에서 볼 수 있습니다.
용도는 뭘까요??

아시겠지만 테이블뷰는 몇개의 데이터만 뿌릴 수 도, 수 백개의  리스트를 출력하기도 합니다.
그런데 과연 출력할 데이터가 수백개일때 셀도 수백개를 메모리에 할당하는 것일까요?

답은 당연히 "아닙니다"

static NSString *CellIdentifier = @"Cell";

 
여기서 @"Cell"이 바로 키(key) 입니다.
셀에서 하나, 혹은 몇개만 할당 후 

[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

이 코드 한줄로 할당한 셀(cell)을 찾아(deque) 재활용(reuse)하는겁니다


이제 이 함수가 이해 가시나요?


모르셨던분들은 메모리가 크지않는 아이폰에서 이 함수의 존재가 달리 보이실겁니다.



이제 제가 이야기하고자 하는 것의 본론으로 들어가보죠.


많은 분들이(심지어 몇몇 기본서에서도) 커스템셀의 사용법을 알려줄 때(xib생성방식으로 할 때)


      CustomTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellName];

if (cell == nil) {
NSArray* nib= [[NSBundle mainBundleloadNibNamed:cellName owner:self options:nil];

    cell = [nib objectAtIndex:0];        

}


이렇게만 설명하고 끝이납니다.


자 우리는 이때 의심을 한번 가져봐야 합니다. 과연 위의 코드로 셀을 생성할 때 저 

dequeueReusableCellWithIdentifier

로 리턴된값이 항상 nil일 수도 있지않을까 라고 말이죠.

근거는 간단합니다.

커스텀이 아닐때와 비교해보면 말이죠.




cell = [[[UITableViewCell allocinitWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] 


NSArray* nib= [[NSBundle mainBundleloadNibNamed:cellName owner:self options:nil];

cell = [nib objectAtIndex:0];        


자 이제 의심이 가기 시작하시나요?


눈치채셨겠지만 기본 셀은 reuseIdentifier라는 인자로 구분자를 넘겨줌니다.

하지만 커스템셀생성시엔 전혀 그런 과정이 없죠.

따라서 tableview에는 셀이 어떠한 Identifier로 큐잉이 되지 않는거죠.


자. 그렇다면 해결법은 무엇일까요??

간단합니다. 저 identifier를 적어주면 되는것이지요.





저것을 적어주지않고 그냥 해서 스크롤 내릴때마다 메모리에 셀이 계속해서 올라가게 되기 때문이죠.

모두들 CustomTableViewCell사용시 주의하세요~!
Posted by IanMK2