NSNotification
을 appDelegate에 생성합니다.NSNotification이 셀렉터를 호출하지 않음
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkRegister:) name:@"checkRegister" object:nil];
return YES;
}
-(void)checkRegister:(NSNotification *) notification{
//Some code
}
그리고 다른 클래스에 통지를 게시하고있다 :
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(@"%@",theXML);
[theXML release];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData: webData];
[xmlParser setDelegate:self];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
[xmlParser release];
[connection release];
[webData release];
if(strUserName != NULL)
[[NSNotificationCenter defaultCenter] postNotificationName:@"checkRegister" object:nil];
}
문제는 checkRegister가 호출되지 않습니다 것입니다.
누군가 나를 도와 줄 수 있습니까?
감사합니다,
Nitish
strUserName
그래서 확실히,
NSLog(@"%@", strUserName)
을 시도 할 것을 어디가 표시되지 않는 경우
@"checkRegister"
통지의 목적은, 당신이 당신의
if(strUserName != NULL)
체크가 무엇
여기서 'strUserName'이 (가) 설정되어 있습니까? 통지가 게시되는 것을 어떻게 알 수 있습니까? 그 줄에 중단 점을 놓고 전화가 왔는지 확인 했습니까? – user1118321
구문 분석시 설정됩니다. 그것은 문제가되지 않습니다. 메소드 checkRegister를 호출 할 수 없습니다. – Nitish