开发者

How do I write an IF ELSE to check string contents of an array?

开发者 https://www.devze.com 2022-12-24 01:41 出处:网络
I\'m trying to write an IF ELSE statement to enable shipping, If user doesn\'t add an address the array contents remain as \"-\" & \"-\" for the two items in the array.I want to check to see if th

I'm trying to write an IF ELSE statement to enable shipping, If user doesn't add an address the array contents remain as "-" & "-" for the two items in the array. I want to check to see if those are in the array, if they are then I want to enableshipping.

Here is the code for getting the array:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullFileName = [NSString stringWithFormat:@"%@/arraySaveFile", documentsDirectory];
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName];

How do I write this first line to look for the "-" & "-"?

if ([fullFileName isEqualToString:@"-","-"]) 
{
[nnNEP EnableShipping];
}
else {
    [nnNEP DisableShipping];
}

Thanks,

开发者_Python百科michael


I think you want to check the contents of the first two items of the array and not fullFileName.

For example:

if ([[array objectAtIndex:0] isEqualToString:@"-"] 
      && [[array objectAtIndex:1] isEqualToString:@"-"])
{
    [nnNEP EnableShipping];
}
else
{
    [nnNEP DisableShipping];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消