I want the number of Spaces in OSX snow leopard.
If I use 4 spaces, I want that number 4!
I can't find a function or a class related with that.
Information about Spaces is stored in Dock preferences. You can access the preferences via NSUserDefaults to get the number of rows and columns, and the number of spaces is the product of those:
NSDictionary *dockPrefs = [[NSUserDefaults standardUserDefaults]
persistentDomainForName:#"com.apple.dock"];
int rows = [[dockPrefs objectForKey:#"workspaces-rows"] intValue];
int cols = [[dockPrefs objectForKey:#"workspaces-cols"] intValue];
int nspaces = rows * cols;
Related
I am developing an camera app ,and showing the taken photos in thumbnail view with the numbers .i am displaying the numbers from array index value in ascending order.Like this.In this image numbers are in 1 , 2, 3, i want the numbers in 3 ,2 ,1
Now i want the numbers in descending order.Please help me to do this .my code is ..
NSString *the_index_path = [NSString stringWithFormat:#"%li", (long)indexPath.row+1];
Cell.waterMark_lbl.text = the_index_path;
this is code is in cellforitem at index method in collection view .
Thanks in advance !!!
You can rearrange the data model in reverse order and from there the data will be displayed.
Plan B, more convoluted, it would not change the order. When you have to show the cell 0, display the last, with cell 1 shows the penultimate, etc. You should generate a new indexPath every time you have to show the data.
The other option I understand is that for the first cell you want to show the last number. The operation would be similar, but without generating the new indexPath.
You have to do the subtraction of the total number of elements. Suppose the total number of elements is NUMBER_OF_ELEMENTS
Cell.waterMark_lbl.text = [NSString stringWithFormat:#"%li",NUMBER_OF_ELEMENTS - indexPath.row ]
In the case of reorder the cells without reorder the data, you have to créate a new indexPath and get the data value for display
NSIndexPath *ip = [NSIndePath indexPathForRow:NUMBER_OF_ELEMENTS - indexPath.row inSection:indexPath.section ]
sorry for lexical errors. I have the objective c somewhat forgotten
My dictionary looks like this
#{#"Blue": #"Big",
#"Red": #"medium",
#"Yellow": #"small"}
I would like to know that the highest key length is 6, because Yellow is the longest key
You can try this. Suppose a is your dictionary. You can find the source here: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/CollectionOperators.html
NSArray *array = a.allKeys;
NSNumber* maxLength= [array valueForKeyPath:#"#max.length"];
NSLog(#"Longest is %lu",maxLength.integerValue);
I have a table to show searchData in iOS with UISearchBar.
When i search with keywords, i retrieved data into NSMutableArray.
There is alot of data in NSMutableArray.
I just want to show about 20 datas in tableView.
Normally i used data to show in tableview,
return [self.myArrayData count];
It's show entire data from NSMutableArray.
I want to limit data count to show in tableView.
How can i limit that data count?
Thanks for helping.
NSInteger count = [self.myArrayData count];
if (count > 20) return 20;
return count;
I want to select a given row in the UTTableView from a index but need to know also the section index.
int localCurrentIndexPath = 9;
NSIndexPath *scrollIndexPath = [NSIndexPath indexPathForRow:localCurrentIndexPath inSection:??];
I need fill in the inSection part. Do I need to supply the inSection value?
Yes. If you only have 1 section, then use 0.
I have 2 NSArray's that are holding values...
For example NSArray 1 has values 1 2 4 in it
and NSArray 2 has values 1 2 4 5 6 in it.
How can I write code to compare these 2 arrays to get the following information...
Count the values that are the same (so in this case 3) and count the values that are not the same (in this case 2).
I am simply populating the arrays like this:
NSString *s = #"1,2,4";
NSArray *numbers = [s componentsSeparatedByString:#","];
where *s is actually getting the text from a UITextField. If sorting mattering in comparing can you show me code to sort to make sure the user doesnt put the numbers in order?
If you are fine with sets instead of arrays, you can use NSMutableSet instead of NSArray. NSMutableSet has nice methods like intersectSet: and minusSet:
I would probably use the following method of the NSArray class:
enumerateObjectsUsingBlock.
and code the block testing for membership in the other array with the method:
indexOfObjectIdenticalTo.
If this isn't clear to you let me know.