I need a bit of help on a app i'm developing.
The app is containing two tableviews (two different xib files with view controllers), named RootViewController and addFavorite. Both of them has the subclass "UITableViewController".
The first uses CoreData to save the users favorites.
The other one collects a list of data from a txt file on the internet.
I know how to set them up seperatly, but I'm trying to make a app where you add cells to the coredata-list from the tablev nr. 2. The user should - when clicking on the "add cell" button in view one, be redirected to view 2, where the user selects a cell, wich is being added to the tableview nr. 1, and then is being stored in the core data.
Why not just refactor you code a bit to abstract the data out into an NSMutableArray and populate your UI from that?
Related
I'm creating an app for iPad, and because of their size decided to do something a little different. I'm creating something like this:
I am using two UITableView in a UIView. I need to display data 'product categories' in the first TableView and 'products' in the second TableView.
The problem is display data in two tables with direferentes contents.
Another detail: When a category is selected, the table 'product' is recharged with other data of other products.
My question is: How can I display data in two different TableView in the same View?
Just add two Containers to your View Controller and drag from the container view to your desired Table View Controller and click embed. Then you'll need to make two separate UITableViewController Cocoa files and assign them to the table view in your Identity Inspector.
In this picture I've already attached the container on the left to my Table View Controller on the left.
I am new to stack overflow and a student currently learning objective-C at university. I am building an APP for the science museum in London and I'm creating an events planner.
I have two table views set up in two different View Controllers.
The first View controller and table view is called "Events" and it holds all of the current days events. When you click on an event, it goes into a new View Controller, gives more information about the event and has a button to "Add To Events", which pops up an alert saying: "Are you sure you want to add this to your events?" with an add button and dismiss button accordingly.
The information in this table view is populated using three NSMutableArray's. (One for title, subtitle and image).
The second view controller has an empty table view inside it. I am trying to make it so whenever a user finds an event they like, they can click into it, see more info and if they want to add it to their own events page, they can. I have got the "Add" button of the alert responding using an NSLog message, so the code to implement the adding to events would go there.
My question is, if i click on the first event, and then choose to add it to my events, how do i send the information of that specific tableviewcell that i clicked to display in the second view controllers table view ?
I have looked all over the place for information regarding this and have taken an abundance of Lynda courses online about IOS and objective-C, but I haven't been able to figure it all out.
Can anybody help?
First of all you shouldn't use three NSMutableArray's to populate your cells. Create one NSMutableArray and populate it with NSDictionarys with a key for the title, the subtitle and the image. Or even better: create a custom model (subclass of NSObject) for your Events and populate the NSMutableArray with those.
Now just like your NSMutableArray is the data source for your first table view controller you need another NSMutableArray as the data source for the second table view controller. When a user now clicks on "Add To Events" all you have to do is add the Event (Model or Dictionary) to the NSMutableArray of the second table view controller and either call - (void)reloadData on your table view so that it reloads ALL data or use the "Inserting, Deleting, and Moving Rows and Sections" methods from the UITableView Class Reference. This would be the better approach because it does not reload data that does not need to be reloaded.
I am developing an iphone app for a class project and am displaying a bunch of different products. I am trying to create a favorites page where users can add one of the products to their favorites page. The app is set up with a bunch of different tableviews to display the different products along with their piture, name, price, and description. I want the user to either click on my addtofavorites button I will add to each of the table view cells or I was wandering if I can just use the didSelectRowAtIndexPath method in the tableviews to add all that information to the favorites table view. Thank you
First, look into following the MVC pattern,
a good introduction: https://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
That being said, I'd have a products UITableView, in a view controller. The user can then select the view controller and in the didSelectRow: method, find out which product was selected to sou can pass the data through a delegate patterns (other ways include target-action, NSNotification, etc.) for example like this: (good example of passing data: Passing Data between View Controllers) to a separate view controller which would hold your favorites table view. Make sure the model is separate from both the products view controller and favorites view controller so you can save all the name, price, etc whatever properties you want to save.
perhaps all of this would be contained in a UITabBarController so it's easier for the user to go back and forth between products and favorites.
i have a view(page) with lots of textfields,date pickers, etc. This page is displayed using presentModalViewController. Now i want to save the data entered in the textfields to the tableView. Each textfields in the page corresponds to the column in the tableview.
I want to save the page's data on click of a button to the tableview as row wise.
Any Help !!
You could use a protocol and delegate object. Here is a simple example that will show you how to accomplish that:
http://www.theappcodeblog.com/2011/04/15/passing-data-between-views-tutorial-using-a-protocol-delegate-in-your-iphone-app/
Your View is presented from a ViewController, which is Controlling the View.
On clicking the save button on the View, the ViewController can pull the data from the fields in the View, and save them into a Model object which you can then add into your UITableViewDataSource array (or whatever you have to load data into your table).
You can then tell your UITableView to update row at index path, and it will pull the new data from the datasource and update your table.
Voila....
... a cleverer (is that a word) approach would be to bind your Model properties to your View elements (from your controller), so as they are updated, the model changes. The table could be using KVO to listen for Model changes and update their view components at the same time.
I have a multiview application using a tab bar to switch views. One is a pickerview while the other two are a table view and a view with 4 text fields (and one other table view that just contains instructions on how to use the app). I want to use core data to save selected rows in the picker view and also save strings that are entered in the text field view. The table view will obviously display all these saved results. So how do I link all these together? Do I create an abstract class just for the core data methods (including the fetchedResultsController) so each view controller can subclass and access the managedobjects and methods from said abstract class? Or is there a better way to do this?
What I would do is implement a <UITabBarDelegate> class to act as the hub for data for the tabs, since they're all operating on the same data set. When a tab is selected, hand it the NSManagedObjects it needs for display (in the case of the history tab, that will be your main array of objects...). You'll minimize repetition and the need to hand around the key Core Data objects (NSManagedObjectContext, etc).