C# 要将目标c函数转换为Xamarin iOS吗
我有一个目标c函数C# 要将目标c函数转换为Xamarin iOS吗,c#,ios,objective-c,binding,xamarin.ios,C#,Ios,Objective C,Binding,Xamarin.ios,我有一个目标c函数 (void)_refreshUserList { [[VoiceMessageController sharedController].channelSwitcher.currentChannel fetchUsersWithCompletion:^(NSArray *users, NSError *error) { NSMutableArray *newUsers = [[NSMutableArray alloc] init];
(void)_refreshUserList {
[[VoiceMessageController sharedController].channelSwitcher.currentChannel fetchUsersWithCompletion:^(NSArray *users, NSError *error) {
NSMutableArray *newUsers = [[NSMutableArray alloc] init];
[users enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[newUsers addObject:obj[kVLChannelUserInfoKeyUser]];
}];
if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Users Fetching Error" message:@"Can't fetch users" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[errorAlert show];
});
} else {
self.users = newUsers;
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
}];
}
我需要使用一个等价的Xamarin c#
函数
(void)_refreshUserList {
[[VoiceMessageController sharedController].channelSwitcher.currentChannel fetchUsersWithCompletion:^(NSArray *users, NSError *error) {
NSMutableArray *newUsers = [[NSMutableArray alloc] init];
[users enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[newUsers addObject:obj[kVLChannelUserInfoKeyUser]];
}];
if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Users Fetching Error" message:@"Can't fetch users" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[errorAlert show];
});
} else {
self.users = newUsers;
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
}];
}
我试图绑定的函数是:
(void)fetchUsersWithCompletion:(void (^)(NSArray *, NSError *))completionHandler;
我能够成功地将其转换为Xamarin c#
方法,即:
void FetchUsersWithCompletion(Action`<NSArray, NSError> `completionHandler);
void FetchUsersWithCompletion(操作``completionHandler);
现在的问题是我得到的输出是
NSArray
。如何将其转换为NSObject
?我大致算出了这个
这是我的等效c代码:
void fetchusers完成(NSArray[]arg1,NSError arg2)
{
List userid=new List();
for(int i=0;i