Sunday, May 12, 2013

NSString completePathIntoString caseSensitive matchesIntoArray filterTypes example ios

completePathIntoString: caseSensitive: matchesIntoArray: filterTypes:

Interprets the receiver as a path in the file system and attempts to perform filename completion, returning a numeric value that indicates whether a match was possible, and by reference the longest path that matches the receiver.
- (NSUInteger)completePathIntoString:(NSString **)outputName caseSensitive:(BOOL)flag matchesIntoArray:(NSArray **)outputArray filterTypes:(NSArray *)filterTypes
Upon return, contains the longest path that matches the receiver.
If YES, the methods considers case for possible completions.
Upon return, contains all matching filenames.
An array of NSString objects specifying path extensions to consider for completion. only paths whose extensions (not including the extension separator) match one of those strings.
Return Value of [NSString completePathIntoString caseSensitive matchesIntoArray filterTypes ]
0 if no matches are found and 1 if exactly one match is found. In the case of multiple matches, returns the actual number of matching paths if outputArray is provided, or simply a positive value if outputArray is NULL.
Discussion of [NSString completePathIntoString caseSensitive matchesIntoArray filterTypes ]
You can check for the existence of matches without retrieving by passing NULL as outputArray.
Note that this method only works with file paths (not, for example, string representations of URLs).
Example of [NSString completePathIntoString caseSensitive matchesIntoArray filterTypes ]
CGDirectDisplayID displeys[2];
CGGetActiveDisplayList( (int)[[NSScreen screens] count], displeys, nil );

NSMutableArray* arrayProf=[[NSMutableArray alloc] init];

for (int q=0;q<[[NSScreen screens] count];q++){

uint32_t vendor = CGDisplayVendorNumber(displeys[q]);
uint32_t model = CGDisplayModelNumber (displeys[q]);

NSString *str=[[NSString alloc] initWithFormat:@"%0x",vendor];
NSString *str2=[[NSString alloc] initWithFormat:@"%0x",model];

NSArray *array;
NSArray *arrayT=[[NSArray alloc] initWithObjects:@"icc",nil];

[@"/Library/ColorSync/Profiles/Displays" completePathIntoString: nil
caseSensitive: NO
filterTypes: arrayT];

[arrayT release];

for(int i=0;i<array.count;i++){
[arrayProf addObject:[[[array objectAtIndex:i] componentsSeparatedByString:@"/"] objectAtIndex:5] ];

for (int i=0;i<[arrayProf count];i++){
NSString *strModel=[[NSString alloc]initWithFormat:@"%@%@",
[[[arrayProf objectAtIndex:i] componentsSeparatedByString:@"-"] objectAtIndex:2],
[[[arrayProf objectAtIndex:i] componentsSeparatedByString:@"-"] objectAtIndex:3]];

if (([[arrayProf objectAtIndex:i] rangeOfString:[str uppercaseString]].location!=NSNotFound)&&
([strModel rangeOfString:[str2 uppercaseString] ].location!=NSNotFound))
if (q==0){
displayFirstName = [[NSString alloc] initWithFormat:@"%@",
[[[arrayProf objectAtIndex:i] componentsSeparatedByString:@"-"] objectAtIndex:0]] ;
displaySecondName = [[NSString alloc] initWithFormat:@"%@",
[[[arrayProf objectAtIndex:i] componentsSeparatedByString:@"-"] objectAtIndex:0]] ;
[strModel release];

[str release];
[str2 release];
[arrayProf removeAllObjects];

[arrayProf release];