Best view architecture for drilldown UITableview - iphone

Basically I want to recreate the "filebrowser" ("drilldown" Tableview) from the DropBox iPhone app using a UITableview and the DropBox SDK.
The SDK has a method restClient which, if called, returns the paths for all the files and folders at a given path. E.g. [self.restClient loadMetadata:#"/"]; or [self.restClient loadMetadata:#"/Photos"];
Currently the table gets populated by an array filePaths wich in its turn get's populated with paths by a call to the restClient method.
My initial idea was to create an array which helped me find out if a selected cell contained a path for a file or a folder - and in case of the latter would use pushViewController to load the same view but would populate filePaths by doing this [self.restClient loadMetadata:pathInSelectedCell];
I found out that this isn't the right way at all to tackle this problem (for numerous reasons), but I wouldn't know a way to do it differently.
What would be the right architecture for this problem?
Thanks in advance!
N.B. DropBox doesn't allow recursive directory/file listing.

I fixed it!
Turns out the best way for me was to pass the filePath to the newly created object thru a constructor.

Related

Unknown class in Interface Builder file

Why am I still getting this error when I run my iPhone app? The file is a ViewController that I have been working to delete and replace, but it just won't die. As far as I know, I don't have any reference (string or otherwise) to this file in my project.
I have deleted the related file (I'm trying to get rid of it.)
I have cleaned the project and rebuilt.
I have "Reset Content and Settings" in my simulator.
I have done a grep (grep -i -r "TheClassName" *) and nothing matches except my UserInterfaceState.xcuserstate file.
I have searched the code using XCode's Find/Replace tab.
I have double checked my Build Phases and am pretty sure it isn't in there (its a large project).
Any other ideas? I've spent way too many hours trying to figure this simple thing out; I must be missing something.
Thanks!
Check your nibs or storyboard, and make sure none of your views are set to the class!
I finally fixed the problem after trying it on multiple machines over the course of almost 2 days! I will not be thwarted!
I tracked the problem down to a call to setViewControllers on a UINavigationController which is called on initialization of the application. I was always being passed 3 objects (there are 3 panes in the navigation controller). Even though I had deleted the third object, as previously explained, three objects would always be passed in. The class type of the first two was correct, but the third would just be a UIViewController. Curiously, this view controller had a nibName which corresponded to the object file and Xib file that I had previously deleted. Of course, when view was called on this borked UIViewController, it would crash since the corresponding nib had obviously been deleted. Remember, the textual name of this object or Xib could not be found in my directory with grep, so I have absolutely no idea how in the world it came into existence when I ran my app.
So, I figured the app may not have been cleaned properly. I double and triple checked this. I even validated that my Workspace settings were correct (File->Project Settings->Advanced). The app was indeed being recompiled fresh every time.
Secondly, I started thinking that perhaps the object was being set by some other means. Working backwards, I added some breakpoints and found out that initWithCoder was being called on the parent UINavigationController--this was eventually working down to call the setViewControllers on the object and assigning the three view controllers (one of which was the offending one). I could easily see from the call stack that the Nib file that was being loaded was deserializing something offensive.
So, I started digging into my Xib file. Of course, the object name wasn't in the file (as expected since the grep didn't find anything). I deleted and recreated the portion of the Xib that included my root UINavigationController. This ended up changing the Object ID and ref within the Xib file.
Secondly, I created a new Xib and UIViewController with the same names as the one which I had previously deleted, hoping that Xcode might be happy if I created and then re-deleted them. I then compiled, re-deleted them, updated by Xib file yet again, reverified with grep that yes, indeed, nothing existed with that name.
And it worked. After spending multiple days on this issues, I'm fairly sure that there is a bug here in the interface builder, but do I want to revisit this problem to file a bug report? Absolutely not...
In my case, I solved an issue by name of Custom class name of View instead of Custom class of ViewController. By mistake i added like this for view as shown below.
It Should be for ViewController like this.
This is in my case, for you may be it's related with another component.
This happens when the view class is in a framework. Select the framework's module. Example with a CocoaPod: HSegmentControl.
Make sure when you add or rename or move files around especially in folders, that when you add them you:
A. Create Groups, not references they don't usually read in.
B. Check the boxes for the apporpriate "Product(s) or Target(s)" you want to add the source to.
Another thing to try :
I had to toggle "Inherit from Target" under the "Module" control of "Custom Class."

How to check if a word is defined in the English dictionary in cocoa-touch?

I am trying to make a crossword app for IOS but i Don't know that how to check if a string is valid english word or not.
How can i check it.
Is there any API or online facility to check it.
Thanks in Advance
Easy to do in iOS5 using the UIReferenceLibraryViewController class' +dictionaryHasDefinitionForTerm: method.
A UIReferenceLibraryViewController object provides a dictionary
service to look up the definition of terms. You create and initialize
a reference library view controller using the initWithTerm: method.
You pass the term to define as the parameter to this method and the
definition is displayed. You can present this view controller modally
or as part of another interface. On iPad, you can set the reference
library view controller as the content view controller of a
UIPopoverController object. Optionally, use the
dictionaryHasDefinitionForTerm: class method to check if a definition
is available for a given term before creating an instance—for example,
use this method if you want to change the user interface depending on
whether a definition is available.
There is no API for this.
In order to do this, you will need to have a dictionary file (text file or database) in your application bundle. One of the faster ways to check will be to load the dictionary into memory when the application launches so you don't have to read the file for each word. This may be overkill if you simply want hardcoded crosswords, but if you are randomly generating them then this is a must.

Creating detail view content programmatically?

I am making an app which uses a splitviewcontroller and will have over 100 different pieces of content. I want to make it so when I select a row, the content changes dynamically. Before, I was creating 100 nib files and separate view controllers before realizing the inefficiency.
I want different labels shown in the detail view when I select a row.
As a guide, I am using the MultipleDetailViews sample code provided by apple.
Also, if anyone can help me out with how to have a button for back and forward (changing table view content) that would be great!
If they are the same just different labelled views, then you could create a single nib file with a view that has all the common elements and then perhaps, create a small template view in the nib which is not contained in the main view and is hidden by default, every time you switch to a new page you can the use you can then use you template view to build the fields for you page. You could also have a few different template views for the different kinds of fields you want to display. To store all this information to drive all of this, you can create simple property list files for each page which contain information like the field title, order, my type or width. Getting the path to a property list file from you app package is easy with methods like [[NSBundle mainBundle] patterForResourceOfName:extension:];, Using properties list can make it easy to change you app, it is even possible to add features like uploading of new nibs without having to resubmit you app to apple, just do a periodic search for new property list files from some server, parsing PropertyList files is really easer too, NSDictionary and NSArray all serialise them selves as property list.

How do generate a UITableViewController that is filled with all the files in the app document folder?

My app is saving certain files. I need to be able to load the files up and show in a UITableViewController.
Thanks
You can query the Documents folder and then use that to populate a table view.
To get the contents of a directory (and perform other file operations), you can use the NSFileMananger class. Specifically, look into the contentsOfDirectoryAtPath:Error method and the similar ones.
Essentially, what you want to do is to store those results in an array or collection and then display them in the table view. You can use the standard UITableViewDelegate and data source methods.

What is the three20 method of passing objects between view controllers?

I have a basic RSS Reader I made from three20 tutorials using TTLauncherView as a menu to different feeds and TTTableViewController to show the feed list.
However, I am stuck at the point where from the feed list I click to view the feed item details. I use TTTableImageItem to display my feed items and I'm clueless as to how I am to use the URL variable in said TTTableImageItem to pass objects to the view controller showing the feed item.
I did some searching and I am lead to think that this cannot be done except via TTURLRequest, which leaves me even more confused.
Most of my code is adapted from IOSGuys tutorial, which uses a custom data source, data model and parser. I have tried making the data source and data model a singleton but to no avail and I'm unsure if that's even the best way to proceed for something as (presumably) simple as this.
Ideally I intend to pass the entire array of feed items with another argument for the index so that I can make use of UIPageControl to swipe between feeds when I'm at a more in-depth view.
Much help is appreciated! I have been spending too long looming around already!
The usual way of doing this is to have some sort of global singleton Data Manager class that manages the data models through Core Data, In-Memory Stores or other ways. Each model would have some sort of unique identifier. Doing it this way lends itself to a URL only stack needed to recover your navigation history without having to write state out to file in order to restore. You also can bring up any page in the app at any place with only a single URL. Using a URL scheme only then becomes trivial as you can do something like:
yourapp://blogs/jd82kd9
and have the blog view controller's init method contact the Data Manager for the blog with the unique identifier of jd82kd9
In your navigator's mappings, you would have something like this:
[map from:#"yourapp://blogs/(initWithBlogID:)") toViewController:[MyBlogViewController class]];
and then the initWithBlogID method would have the signature:
- (id)initWithBlogID:(NSString *)blogID;
see also Three20 : how to pass a class of objects between 2 views