2
저는 총 초보자입니다. 제발 끔찍한 일을하고 있다면 용서해주세요.NSString을 NSDate로 구문 분석하는 중 오류가 발생했습니다.
인스턴트 메신저 scanf
섹션에서 사용자 내가 예에서 지정하는 형식의 생일,하지만 점점 오류 받으려고 : format specified type char * but the argument has type NSString
이
내가 그것을 어떻게
를 해결할 수 를?int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *input;
NSLog(@"Please enter your birthday, for example: 09-01-1984");
scanf("%s", &input);
NSDate *today = [NSDate date];
NSDate *bDay = [NSDate dateWithNaturalLanguageString:input];
NSLog(@"%lu", [bDay elapsedDays:today]);
}
return 0;
}
그는 scanf와가 (문자의 배열에 대한 포인터)를 C 문자열을 반환하지만 ObjC의 API가있는 NSString 소요 의미합니다. NSString은 char * – nielsbot
@nielsbot과 같지 않습니다. 무슨 뜻인지 모르겠군요. 제공 한 코드에 오류가 있습니까? – trojanfoe
고마워요! 이 작품 :) @ trojanfoe – JohnBigs