iPhone의 일부 데이터를 암호화하는 도우미 메서드가 있습니다. 장치가 잠겨서 작업이 중단되면 방금 처리 한 파일을 삭제하려고합니다. 따라서 메서드가 호출되면 notifiaction listsner를 추가합니다.NSNotification을 수신 할 때 "관찰하지 말 것"경고 및 관찰 중지 방법?
두 가지 문제 : 1. 내가 청취자를 추가하는 데 사용하는 방법이 더 이상 사용되지 않는다는 경고가 나타납니다. 내가 어떻게 그럴 수 있니? 2. 처리가 완료되면 청취자를 없애고 싶습니다.하지만 어떻게해야합니까?
NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.ProtectedDataWillBecomeUnavailable, Handler);
이 모든 관찰자에 적용, 예컨대 : 등등
UIKeyboard.WillHideNotification
UIKeyboard.WillShowNotification
UIDevice.OrientationDidChangeNotification
과 :
private static foo(string sDestPathAndFile)
{
NSNotificationCenter.DefaultCenter.AddObserver ("UIApplicationProtectedDataWillBecomeUnavailable",
delegate(NSNotification oNotification)
{
Util.DeleteFile (sDestPathAndFile);
throw new InvalidOperationException ("Protected data became unavailable - device locked?");
});
// Do some processing here.
// ...
// Now get rid of the notification listener - but how?
}
감사합니다. 둘 다 작동했습니다. – Krumelur