I am working on one app in which I want a feature to block call. If i am passing static values to addBlockingEntryWithNextSequentialPhoneNumber
it's blocking numbers but when i'm passing array in addBlockingEntryWithNextSequentialPhoneNumber
it's not blocking numbers. I have logged my array in Appdelegate and it looks fine.
Appdegate Code:
NSArray *sortedArr = [lockedArr sortedArrayUsingSelector:@selector(compare:)];
[DEFAULTS setObject:sortedArr forKey:@"SortedBlockedUsers"];
NSArray<NSNumber *> *blockedPhoneNumbers = [DEFAULTS objectForKey:@"SortedBlockedUsers"];
for (NSNumber *phoneNumber in blockedPhoneNumbers) {
NSLog(@"phoneNumber == %lld", (CXCallDirectoryPhoneNumber)[phoneNumber unsignedLongLongValue]);
}
output is: phoneNumber == 918849494978 phoneNumber == 919142142124
HandlerClass code:
NSArray<NSNumber *> *blockedPhoneNumbers = [[NSUserDefaults standardUserDefaults] objectForKey:@"SortedBlockedUsers"];
//NSArray<NSNumber *> *blockedPhoneNumbers = @[ @918823514521, @919586112211 ];
for (NSNumber *phoneNumber in blockedPhoneNumbers)
{
[context addBlockingEntryWithNextSequentialPhoneNumber:(CXCallDirectoryPhoneNumber)[phoneNumber unsignedLongLongValue]];
}
答案 0 :(得分:0)
最后在调试我的扩展类之后,我发现问题是从NSUserDefaults
为数组赋值。我们必须使用NSUserDefaults SuiteName
来保存和检索值,以便与Extension类进行交互。