Contents

Views 26597 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
# NSData 클래스
파일처리 등에 이용하는 바이트 배열 클래스 (1byte 기준)

메서드
-(id)dataWithBytes : (const void *)bytes length:(NSVinteger)length
          생성자                배열           주소                     개수
-(id)initWithBytes : (const void *)bytes length:(NSUinteger)length
       초기화             어떤 타입의 포인터도 상관없음, integer를 넣으면 깨질 수 있음.
-(id)dataWithData:(NSData*)aData
          생성자
-(id)initWithData:(NSData*)aData
-(NSUinteger)length  // 
-(void)getBytes:(const void*)bytes
                         bytes에게 주소를 리턴
-(NSString *)description

ex) NSString 과 NSData 와 char * 사이의 변환
#import <foundation/foundation.h>
/* 안써도 됨 
#import <foundation/NSString.h>
#import <foundation/NSData.h>
*/
int main(int argc, char * argv[])
{
    unsigned char buf[20]; // 저장하기 위해 생성 
    NSString * message = @"Test Conversion";
    const char * str = [message UTF8String]; // 일반 char type 으로 변환 

    // 생성자이므로 메모리할당이 필요없음
    NSData * myData = [NSData dataWithBytes:str length:strlen(str)];

    // NSString => NSData    // 문자의 개수 리턴 
    [myData getBytes:buf]; // char 배열로 변경 
    int i;
    for (i=0; i<[myData length];i++)
    {
        NSLog(@"%c",buf[i]); 
    }
    system("pause");
    return 0;
}


# NSMutableData 클래스
변경가능한 Data 클래스
삽입, 삭제(remove로 시작), 갱신에 관련된 메서드가 존재
인덱스 위치에 있는 인스턴스를 삭제하고 새로운 인스턴스를 삽입

NSData 로부터 상속됨
add : 뒤에 삽입
insert : 위치에 삽입

?

List of Articles
No. Category Subject Author Date Views
397 Develop [c++] winsock을 이용한 서버,클라이언트와 ssl서버,클라이언트 file hooni 2013.04.23 7643
396 Develop [js] 비만 지수 측정(BMI) ㅎㅎ file hooni 2013.04.23 7639
395 Develop [c++] 초간단 스택 두 가지 방식(class, struct) file hooni 2013.04.23 7638
394 Develop [c++] 윈도우 API 정복 예제 file hooni 2013.04.23 7634
393 Develop [c] 소켓 스트림 서버/클라이언트 (UDP) file hooni 2013.04.23 7619
392 Develop [c] 정수를 2진수로 변환 (재귀,비트연산) file hooni 2003.04.23 7608
391 Develop [c] IP 스푸핑(ip spoof) 소스 - 정리해야 함 file hooni 2003.04.23 7580
390 Develop [php] 웹 응용프로그램(engines) 모음 file hooni 2013.04.23 7574
389 Develop [chm] 윈도우즈에서 디버깅 기법(Debugging Applications) file hooni 2013.04.23 7553
388 Develop [c] 시어핀스키 가스킷..(p.582, A.2 - 두번째) hooni 2003.04.23 7536
387 Develop [php] 데이터를 엑셀,워드 형태로 변환할 때 헤더(ms-office) hooni 2013.04.23 7525
386 Develop [chm] 비주얼 C++ 팁 모음 문서 file hooni 2013.04.23 7521
Board Pagination Prev 1 ... 33 34 35 36 37 38 39 40 41 42 ... 71 Next
/ 71