Created
October 27, 2014 00:11
-
-
Save davidmurray/71885bd167979309d10f to your computer and use it in GitHub Desktop.
Find the first icon list view with an empty spot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static SBIconListView *MTGetFirstAvailableIconListView() | |
{ | |
SBRootFolderController *rootFolderController = [[%c(SBIconController) sharedInstance] _rootFolderController]; | |
SBRootFolderView *rootFolderView = [rootFolderController contentView]; | |
// Attempt to find a model that has an available spot. | |
for (SBIconListView *view in [rootFolderView iconListViews]) { | |
if (![[view model] isFull]) { | |
return view; | |
} | |
} | |
// We couldn't find any available icon list views, therefore we will add a new one. | |
SBRootFolder *rootFolder = [rootFolderController folder]; | |
SBIconListModel *emptyModel = [rootFolder addEmptyList]; | |
if (!emptyModel) { | |
return nil; | |
} | |
SBIconListView *iconListView = [rootFolderView iconListViewAtIndex:[rootFolder indexOfList:emptyModel]]; | |
return iconListView; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment