如果存在任何术语,只需遍历您的 pages 数组并设置一个布尔标志
//
// customstring.m
//
// Created by rbertsch8 on 8/2/13.
//
//
#import "customstring.h"
@implementation customstring
-(bool)hasPrefixArray:(NSArray*)array withbaseURL:(NSString*)baseUrl
{
bool hasprefix = NO;
for(int i = 0; i < [array count] || hasprefix == NO; i++)
{
hasprefix = [self hasPrefix:[baseUrl stringByAppendingString:[array objectAtIndex:i]]];
}
return hasprefix;
}
@end
现在在您的代码中执行以下操作: //导入您的自定义字符串文件 #import NSStringPrefix.h
NSStringPrefix *customURL = yoururl.com
NSString *baseUrl = baseurl.com
NSArray *yourarray = [[NSArray alloc] initWithObjects: @"one", @"two"]
if([customURL hasPrefixArray:yourarray withbaseURL:baseUrl])
{
//dowork
}
更新
在全局类中定义变量。
#define companyOrSiteName @"Company X"
#define baseUrl @"http://www.example.com/" // Set base URL for site.
#define customUrlScheme @"example://" // Set custom URL Scheme for app.
#define openInModal [NSArray arrayWithObjects: @"contact-us.php",@"products/",nil]
#define openInSafari [NSArray arrayWithObjects: @"about",@"products/resources/download",nil]
#define twitterHandle @"Example" // Twitter username without the "@" symbol
#define kTrackingId @"UA-4564564-3" // Set Google Analytics iOS App Tracking code.