NSString * htmlWillInsert = [NSString stringWithContentsOfURL :[NSURL URLWithString:@" http:// xxxxxxxxxx.xxxxxxxxx"]encoding:-2147481280

 error:nil];

NSData * htmlData= [htmlWillInsert dataUsingEncoding:NSUnicodeStringEncoding];

TFHpple *xpathParser = [[TFHpple allocinitWithHTMLData:htmlData];

NSArray * elements = [xpathParser search:@"//td[@class='subject']//a"];

NSArray * elements2 = [xpathParser search:@"//td//a//img[@width='28']//@alt"];

NSMutableArray *final=[NSMutableArray arrayWithCapacity:[elements count]];



for(int i=0;i<[elements count];i++){

TFHppleElement *element = [elements objectAtIndex:i];

TFHppleElement *element2 = [elements2 objectAtIndex:i];

    NSString *titleOfAlips = [element content];

NSString *titleOfAlips2 = [element2 content];

    NSLog(@"[%@] %@",titleOfAlips2,titleOfAlips);

//NSArray * final = [[NSArray allocinitWithString:[element content]];

}

//NSLog(@"%@",titleOfAlips);

 


}

Posted by 김반장78
,
별 내용 아닌데 정보가 없어 한참 고생하기

1. 옵션에 클래스패스 선택 - 폴더 추가선택 - 컴파일된 클래스폴더의 루트폴더를 선택 - 저장

2.레포트쿼리 선택 - JavaBean탭 선택 - 클래스명에 해당 클래스명 직접 입력 - 속성취득버튼 클릭

'프로그래밍' 카테고리의 다른 글

数値  (0) 2011.07.07
[펌] 자바 파일 입출력시 글자깨짐 문제  (0) 2010.12.27
[JAVA] XmlWriter.java  (0) 2010.12.10
C# 과 JAVA 의 이스케이프 코드 차이점  (0) 2010.12.09
[NetBeans] setDisable() 관련 문제  (0) 2010.11.25
Posted by 김반장78
,
Posted by 김반장78
,

u Enabling Static Behavior

n         Objective-C 동적 특징

- 오브젝트용 메모리는 새인스턴스를 작성하는 클래스메소드에 의해 실행시 할당받음

- 오브젝트는 동적으로 형정의 됨. 컴파일시 자동으로 정의된 id형에서 프로그램이 실핼될때까지

정해지지않음

              - 오브젝트 지향 프로그래밍에 높은 유난성을 제공

              - 컴파일러가 id형의 변수의 형체크가 불가능

              - 클래스명을 정적으로 형정의하거나 형정의 시점을 실행시에서 컴파일시로 되돌릴수있게 필요없는

                기능을 오프시킬수 있음

 

n         오버해드 검출 툴

Shark, Instruments

 

n         정적 형정의

Rectangle *thisObject;

- 정적으로 형정의된 오브젝트는 id로 정의된 오브젝트와 동일한 내부구조를 가지게 됨

- 실행시의 오브젝트 처리방법에도 영향없음 id로 동적정의된 오브젝트와 같이 동적 바인딩 됨

Rectangle *thisObject = [[Square alloc] init];

- 위의 경우 thisObject Rectangle의 인스턴스변부뿐아니라 Square의 인스턴스변수도 가지게 됨

(Square Rectangle의 서브클래스)

[thisObject display];

- 메세지 역시 실행시 동적 바인드 됨.

- 위의 메세지의 경우 Rectangle슈퍼클래스의 메소드가 아니라 Square 클래스에 정의 된 메소드를 실행함

 

n         정적 형정의의 특징

- 정적형정의는 조건에 따라 컴파일시 형체크를 할수있음

- 정적 형정의에 의해 같은 이름의 메소드는 같은 반환형과 인수를 가질 필요가 있다는 규칙을 무시할수있음

- 구조체 포인터연산자를 사해서 오브젝트안의 인스턴스변수에 직접 엑세스가 가능함

 

n         형체크

- 정적으로 형정의된 리시버에 메세지를 보내면 컴파일러는 리시버가 응답가능한지를 체크

              응답 불가능한 경우에는 경고발생

              - 정적으로 형정의한 오브젝트를 변수에 할당하면 컴파일러가 호환가능한지를 체크

              호환불가능한 경우에는 경고 발생

Shape *aShape;

Rectangle *aRect;

aRect = [[Rectangle alloc] init];

aShape = aRect;

              Rectangle Shape를 계승하고 있다는 가정하에 위의 경우 호환성 통과

              반대의 경우 호환성 경고

              - 대입 연산자의 한쪽이 id형인 경우 호환성 체크 안함

 

n         Return and Argument Types

- 반환형과 인자형의 경우 동적 바인딩때문에 같은 이름의 메소드의 경우 일치시킬 필요가 있음

- 메세지를 정적으로 형정의한 오브젝트에 송신하는 경우 컴파일러가 오브젝트를 인식하기 때문에

반환형과 인자형을 일치시킬 필요가 없음

 

n         Inherited Class에의 형정의

- 인스턴스는 자신의 클래스나 계승받은 클래스를 정적으로 재정의 할수 있음

Shape *myRectangle = [[Rectangle alloc] init];

- 위의 경우 컴파일러는 RectangleShape로 처리함

BOOL solid = [myRectangle isFilled];

- isFilled메소드가 Rectangle의 메소드라고 가정 위의 메세지는 에러발생

[myRectangle display];

-         display메소드가 Shape에서 인식가능한 경우 Rectangle에서의 오버라이드 여부에 관계없이

정상 컴파일


Posted by 김반장78
,

u Fast Enumeration

n         정의

반복문

              Objective-C 2.0 새로 추가된 기능

NSFastEnumeration 프로토콜을 지원하는 모든 컬렉션(NSArray, NSDictionary, NSSet, NSEnumerator)에서 사용가능.
직접 만든 컬렉션에서 fast enumeration 지원할려고 하면 NSFastEnumeration 프로토콜을 지원하면 된다.

// one
for ( Type newVariable in expression ) { statements }


// two
Type existingItem;
for ( existingItem in expression ) { statements }

 

n         NSArray 예제

NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", nil];
for (NSString *element in array) {
    NSLog(@"element: %@", element);
}
// element: One
// element: Two
// element: Three
// element: Four

 

n         NSDictionary 예제

NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:

@"quattuor", @"four", @"quinque", @"five", @"sex", @"six", nil];
NSString *key;
for (key in dictionary) {
  NSLog(@"English: %@, Latin: %@", key, [dictionary valueForKey:key]);
}
// English: four, Latin: quattuor
// English: five, Latin: quinque
// English: six, Latin: sex

 

n         NSArray ? nextObject 예제

NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", nil];
NSEnumerator *enumerator = [array reverseObjectEnumerator];
for (NSString *element in enumerator) {
    if ([element isEqualToString:@"Three"]) {
        break;
    }
}
NSString *next = [enumerator nextObject];
// next = "Two"

 

n         index를 이용한 예제

NSArray *array = /* assume this exists */;

NSUInteger index = 0;

 

for (id element in array) {

    NSLog(@"Element at index %u is: %@", index, element);

    index++;

}

 

n         아래 두가지 예제는 조건에 따라 일부 처리 요소를 제외할 수 도 있다는 것을 보여줌

NSArray *array = /* assume this exists */;

 

for (id element in array) {

    if (/* some test for element */) {

        // statements that apply only to elements passing test

    }

}

NSArray *array = /* assume this exists */;

NSUInteger index = 0;

 

for (id element in array) {

     if (index != 0) {

          NSLog(@"Element at index %u is: %@", index, element);

     }

      if (++index >= 6) {

          break;

     }

}

 

Posted by 김반장78
,