嗨我有两个nsarrays。
数组A:
arrProductSelection = [[NSArray alloc]initWithObjects:@"English",@"German",@"Russian",@"Chinese",@"Spanish",@"French",@"French",@"French",@"French",@"French",@"French",@"French",@"French",nil];
数组B:
arrProductSelectionB = [[NSArray alloc]initWithObjects:@"deselcted",@"selected",@"selected",@"selected",@"deselcted",@"deselcted",@"deselcted",@"deselcted",@"deselcted",@"deselcted",@"deselcted",@"deselcted",@"deselcted",nil];
我需要比较两个数组并通过比较具有所选值的数组B来从数组A获取值。那就是我应该用逗号作为nsstring将德语,中文和俄语分开。
答案 0 :(得分:3)
试试这个:
//UNUserNotificationCenterDelegate delegate methods to get userInfo
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (_ options: UNNotificationPresentationOptions) -> Void) {
//Called when a notification is delivered to a foreground app.
let userInfo = notification.request.content.userInfo as? NSDictionary
print("\(userInfo)")
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
// Called to let your app know which action was selected by the user for a given notification.
let userInfo = response.notification.request.content.userInfo as? NSDictionary
print("\(userInfo)")
}
答案 1 :(得分:0)
首先我要确保两个阵列都有相同的安全计数器,如
ng-app
答案 2 :(得分:0)
如果你可以制作这种类型的阵列,那么就可以轻松管理。
(
{
flag = deselcted;
name = English;
},
{
flag = selected;
name = German;
},
{
flag = deselcted;
name = Russian;
},
{
flag = deselcted;
name = Chinese;
}
)
==>阵列[(辞典),(词典),...]
答案 3 :(得分:0)
如果你需要一个数组的结果,这是函数:
NSMutableArray*resultArray=[[NSMutableArray alloc]init];
for(int i=0; i<arrProductSelectionB.count;i++){
if ([[arrProductSelectionB objectAtIndex:i]isEqualToString:@"selected"]) {
[resultArray addObject:[arrProductSelection objectAtIndex:i]];
}
}
resultArray有你需要的值。