检查2个数组中是否存在字符串的最简单方法是什么?p/s是否有LINQ方法来替换它?
// Old school method
bool result = false;
var stringArray1 = new string[] { "ABC", "EFG", "HIJ" };
var stringArray2 = new string[] {"123", "456", "ABC"};
for (var i = 0; i < stringArray1.Count; i++) {
var value1 = stringArray1[i];
for (var j = 0; j < stringArray2.Count; j++) {
var value2 = stringArray2[j];
if(value1 == value2)
result = true;
}
}
Run Code Online (Sandbox Code Playgroud) 当我尝试使用extern函数进行marco时,我在Objective C中遇到了链接器问题.知道为什么吗?
头文件
帮助与设备版本进行比较
extern NSString* getOperatingSystemVerisonCode();
#if TARGET_OS_IPHONE // iOS
#define DEVICE_SYSTEM_VERSION [[UIDevice currentDevice] systemVersion]
#else // Mac
#define DEVICE_SYSTEM_VERSION getOperatingSystemVerisonCode()
#endif
#define COMPARE_DEVICE_SYSTEM_VERSION(v) [DEVICE_SYSTEM_VERSION compare:v options:NSNumericSearch]
#define SYSTEM_VERSION_EQUAL_TO(v) (COMPARE_DEVICE_SYSTEM_VERSION(v) == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) (COMPARE_DEVICE_SYSTEM_VERSION(v) == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) (COMPARE_DEVICE_SYSTEM_VERSION(v) != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) (COMPARE_DEVICE_SYSTEM_VERSION(v) == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) (COMPARE_DEVICE_SYSTEM_VERSION(v) != NSOrderedDescending)
Run Code Online (Sandbox Code Playgroud)
.mm文件
NSString* getOperatingSystemVerisonCode()
{
/*
[[NSProcessInfo processInfo] operatingSystemVersionString]
*/
NSDictionary *systemVersionDictionary =
[NSDictionary dictionaryWithContentsOfFile:
@"/System/Library/CoreServices/SystemVersion.plist"];
NSString *systemVersion =
[systemVersionDictionary objectForKey:@"ProductVersion"];
return systemVersion;
}
Run Code Online (Sandbox Code Playgroud)
链接器错误:
Undefined symbols for …Run Code Online (Sandbox Code Playgroud) 我已经为SKStoreProductViewController实现了一个委托.我将该视图控制器添加到关键窗口的视图控制器中.我还在委托函数中实现了一个dismiss视图控制器代码.
问题似乎是这个问题的答案.
Modal App Store不会解雇
但是,这个问题仍然存在于我的情况中.
显示功能
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
NSString *appURL = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/%@/app/id%@",
[[NSLocale preferredLanguages] objectAtIndex:0], applicationID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:appURL]];
} else {
NSDictionary* dict = [NSDictionary dictionaryWithObject:applicationID forKey:SKStoreProductParameterITunesItemIdentifier];
SKStoreProductViewController *viewCont = [[SKStoreProductViewController alloc] init];
viewCont.delegate = self;
[viewCont loadProductWithParameters:dict completionBlock:^(BOOL result, NSError *error)
{
UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
if (viewController)
{ [viewController presentViewController:viewCont animated:YES completion:nil]; }
}];
}
Run Code Online (Sandbox Code Playgroud)
委托功能
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
if (viewController)
{ [viewController dismissViewControllerAnimated:YES completion:nil]; }
}
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来识别外部输入设备。
我注意到 [InputDevice] 类的 Android API 有一个名为 [isExternal] 的函数。但是当我尝试使用它时,它告诉我它无法解析方法。我查看了在线 API 参考并注意到该函数不存在。所以我想知道为什么API中的函数而不是在线参考中的函数。
参考:https : //developer.android.com/reference/android/view/InputDevice.html https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/InputDevice .java
我使用Fabric mac桌面应用程序将Fabric Crashlytics sdk与我的ios应用程序集成在一起.我使用免费的Apple开发者帐户存档我的应用程序.我使用Fabric桌面应用程序上传了应用程序.用我的电子邮件安装.在我的iPhone上打开电子邮件并设置结构Beta webhooks.但每当我不断尝试下载并安装我的应用程序.它将以无法下载应用程序对话框结束.