I can't seem to be able to figure out what it is that's wrong.
The program builds and runs correctly, but X-Code says that build generates issues.
Line 23 (below) indicates 3 warnings as follows:
1- Unused Entity Issue
Expression result unused
2- Format String Issue
More '%' conversions than data arguments
3- Unused Entity Issue
Expression result unused
Heres the code and output...
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *str1 = @"This is string A";
NSString *str2 = @"This is string B";
NSString *res;
NSComparisonResult compareResult;
// Count the number of characters
NSLog(@"Length od str1 %lu", [str1 length] );
// Copy one strig to another
res = [NSString stringWithString:str1];
NSLog(@"copy: %@", res);
// Copy one string to the end of another
str2 = [str1 stringByAppendingString:str2];
NSLog(@"Concatentation %@"), str2;
// Test of two strings are equal
if ([str1 isEqualToString:res] == YES) {
NSLog(@"str1 == res");
} else {
NSLog(@"str1 != res");
}
// Test if one string is <, ==, or > to another
compareResult = [str1 compare: str2];
if (compareResult == NSOrderedAscending)
NSLog(@"str1 < str2");
else if (compareResult == NSOrderedSame)
NSLog(@"str1 == str2");
else
NSLog(@"str1 > str2");
// Convert string to uppercase
res = [str1 uppercaseString];
NSLog(@"Uppercase Conversion: %@", res);
// Convert to lowercase
NSLog(@"Lowercase Conversion: %@", [str1 lowercaseString]);
NSLog(@"Original String: %@", str1);
[pool drain];
return 0;
}
// Program Output
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
sharedlibrary apply-load-rules all
[Switching to process 2148 thread 0x0]
2011-05-17 12:50:29.371 PiOC_15-3[2148:903] Length od str1 16
2011-05-17 12:50:29.373 PiOC_15-3[2148:903] copy: This is string A
2011-05-17 12:50:29.374 PiOC_15-3[2148:903] Concatentation This is string AThis is string B
2011-05-17 12:50:29.374 PiOC_15-3[2148:903] str1 == res
2011-05-17 12:50:29.374 PiOC_15-3[2148:903] str1 < str2
2011-05-17 12:50:29.375 PiOC_15-3[2148:903] Uppercase Conversion: THIS IS STRING A
2011-05-17 12:50:29.375 PiOC_15-3[2148:903] Lowercase Conversion: this is string a
2011-05-17 12:50:29.376 PiOC_15-3[2148:903] Original String: This is string A
Program ended with exit code: 0