2013-06-29 4 views
0

http://tech.pro/tutorial/975/building-an-earthquake-monitor-for-iphone-using-mapkit에있는 멋진 obj-c/ios 앱을 시험하고 있습니다. 지진을 해결합니다.인터페이스에 출력을 제한하는 nsscanner

잘 작동하지만 핀에 제목과 부제목을 추가하고 싶습니다. 안돼. 문제는 인터페이스가 스캔 한 파일의 값만 허용한다는 것입니다! 추가 필드를 추가하려고하면 실패합니다. 것은 그들이 배열에 있다는 것을 압니다. 외모로는 앞으로 나아갈 수 없습니다. 은 여기 내 말은 무엇을 : NSLog 이벤트가 포함 36.238, 나는이 예상

91.0 69.520, 4.200 : 는 NSLog이 이벤트에는 다음이 포함 스케일 4.200 36.238, 69.520, 4.200, 그것은이었다 91.0

가 생산된다 이것에 의해 : TimeUTC, 위도, 경도, 진도, 깊이 2013/06/28,07 날짜 : 45 :

while ([scanner isAtEnd] == NO) { 
     [scanner scanUpToString:@"\n" intoString:&line]; 
     //skip the first line 
     if(count > 0) { 
      values = [line componentsSeparatedByString:@","]; 
      event = [[SeismicEvent alloc] init]; 
      event.title = @"Scale"; 
      assert(event.title); 
      event.subtitle = [values objectAtIndex:4]; 
      assert(event.subtitle); 
      event.latitude = [[values objectAtIndex:2] floatValue]; 
      event.longitude = [[values objectAtIndex:3] floatValue]; 
      event.magnitude = [[values objectAtIndex:4] floatValue]; 
      event.depth = [[values objectAtIndex:5] floatValue]; 
      NSLog(@" Event contains: %@", event); 
      [eventPoints addObject:event]; 

는이 글을 읽고, 23.0, -22.795,171.317,4.9 35 2013/06 /28,07:27:54.1, 3.917,126.013,4.7, 62

필드를 NSLog 할 수 있습니다. 가치는 거기에있다, 그들은 단지 그것을 어디에도 만들지 않는다. 나는 혼란 스럽다.

답변

0
NSLog(@" Event contains: %@", event); 

사용자 지정 개체를 문자열로 변환하려면 [event description]을 호출하십시오.

그래서 SeismicEvent 클래스가 해당 메서드 을 재정의하고 원하는 모든 필드를 표시하도록 구현을 변경할 수 있다고 가정합니다.