I want to pass information like number between two views in navigation controller. But I don't know how.
Thanks
Another option might be using singletons if the "numbers" are just a synonym for your application model. Remember, you should use the MVC-concept!
http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html
Try the SynthesizeSingleton.h macro if you want a tough solution!
You need to use delegates and protocols. Here is a site with an example http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html
Related
http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_4_iPhone_Application_%28Xcode_4%29
I have found this sqlite tutorial on google and it worked great for my requirement.
In this tutorial both adding and retrieving data are done on the same viewcontroller. but i want that 'save' method in the tutorial in one viewcontroller and 'find' method in the other.
And also someone tell me whether this tutorial is an effective way to save data or not.because this is the easiest tutorial I found so far.
You might also create a new class ,or use inheritance (upper class) call it for example "SqliteClass"
that have both the 'Save' and 'Find' method
then you can use any method in SqliteClass from any other class ,,
in case you don't want to use inheritance make sure that the methods in SqliteClass are "class" methods the one begins with "+" not"-"
I used both ways and they work just fine ..
Hope that helps :)
Yes, you can to that. you can have n number of view and can save data from any view controller.
check this tutorial.
http://www.icodeblog.com/2008/08/19/iphone-programming-tutorial-creating-a-todo-list-using-sqlite-part-1/
I have a custom controller action helper that I would like to be able to call from a view script. How can I achieve this?
Solution:
Warning: You probably don't really want to call an action helper from your view script unless you aren't using any dispatch hooks. But if you really, really want to call your action helper:
$helper = Zend_Controller_Action_HelperBroker::getStaticHelper('Myhelper');
Afaik, you can't, and you should not that's MVC. Trying to solve such problem should be a potential warning on your design.
However, in some case you may need to achieve a similar thing.
For example, the flashMessenger() action helper aims to provide a simple way to share messages between requests, however it is not available in the view, you need to manually pass it to the view. I've myself written a wrapper to be able to use as a view helper.
So maybe try to be more explicit on what you're trying to achieve, and we may help you to know if there isn't a good alternative.
I'm new to Objective-C so I may be doing this completely wrong, and if I am please correct me. I am trying to make a separate class in my iPhone app just for skinning buttons. My hope is that this will allow me to reuse as much code as possible but before I spend too much time on it, I would like to know if its possible/a good idea to send a message to a UI Control from another class, and if i can, how should I do it? right now im trying to pass the sender ID to my SkinTools class and message that but it doesn't look like it will allow me to message the layer object.
So, am I just completely off the wall here, or is this possible?
Consider looking into using the delegate pattern.
One could just use the addTarget:selector: method for this purpose. As target set the class you want to send the message to, as selector the method you want to call on the class.
You could add some iVars to your class, like id buttonTarget and SEL buttonSelector and create an initializer like -initButtonWithTarget:selector: to set these values on initialization.
It turns out categories was the answer I needed, then I can just add a skin method to each control I use. I can even put them all in the same file to make it easy to get to.
is it good practice to share the ADD and EDIT screen to use the same UIViewController?
That is in the case where the only real difference would be in one the values would be populated with existing (EDIT).
PS. Some clarification. So perhaps take the simple case where there is just one or two NSString fields (e.g. title & description) - so is there anything wrong (e.g any gottchas) associated with using the same controller/NIB(view) for both EDIT and ADD?
Not sure about "good practise", but...
Populating a Label with one or another string is easy, also easy is hiding buttons or fields on depending if the ADD or EDIT view is displayed.
The problems tend to come when your view has received the user input and then needs to decide whether to modify an existing object or to create a new object.
So before exiting, the view has to decide how to treat user input. If the differentiation is mind boggling complex you are better off with two viewsControllers. If it is a matter of a simple if-the-else in or near the viewWillDisapper method then one view can do.
I would use inheritance in this case. Some base UIViewController and two additional UIViewControllers - one for add, second for editing. You can use one UIViewController too, but it depends on how difficult your task is or isn't. It's too general question.
Can we create xib (with view) programmatically ? If No, why & If yes, How ??
Xibs are just files, too, so there's no technical reason why you wouldn't be able to create one programmatically.
Expect no convenience methods to create xibs however, as their purpose is to circumvent the need to create and configure UI elements programmatically, so what you would like to do is exactly the opposite of what people normally use xibs for.
If you really must create xibs though, just open one in a texteditor - you'll see that it consists of readable xml code. It may take some time to work through all the keys and possibilities, but creating xibs programmatically can be done.
Edit: it's gonna be hard, though.