ios5, ABPersonViewController - notify when person's record is updated? - ios

I have a UITableViewCell that displays person's name from Address Book. When that cell is selected, the person's info is displayed using ABPersonViewController (where editing is ON).
What I want to do is if the person's first name or last name is edited then update that information in the main UITableView.
Is there any Notification or delegate which I can use to convey that information has been updated ?

I couldn't find anything on this so I just reloaded my table.
It would be great if someone can suggest any better solution like through delegate or something.

Related

Passing data to Detail View, actual data or reference ID

Situation
Let’s say there is an iPhone app that shows articles. Articles are loaded from a server.
It has two views.
TableView: Shows list of articles
DetailView: Shows detail of selected article
Problem / Question
I want to know better way of passing data from TableView to Detail View.
Which one of the following is a better practice?
Option 1
Pass an actual Article object from TableView to DetailView
DetailView just displays the Article
Option 2
Pass reference ID of Article from TableView to DetailView
This case, the DetailView loads the article from server by the ID of the Article.
Option2 seems a better design since relation between TableView and DetailView is minimum.
Option1 seems a little bit faster since i doesn’t have to connect to API ever time it loads an article
I understand it depends on situation but i would like to know if there is any reasonable guideline.
You should use a combo of both since many apps such as Facebook also do the same. For eg. if I have a photo that has likes in my notification bar, I can click on that photo and see it even if I do not have an active connection at that time. I will obviously be shown the older data. However at that time, Facebook immediately sends a call to the server and the updated likes are shown.
Therefore it should be ideal to pass the entire object to the next VC and immediately send an async call to the server. Any changes should then be reloaded in your complete data model. Hope this helps :)

How to get the Value of a Cell from a TableView to Another View

I'm going to make this VERY simple because for the past week people are getting confused with this same exact question. I have on TableViewController. When a user taps on a cell on my TableViewController it goes to a DetailViewController which has a button called PAID. When the user taps on the PAID button in the DETAILVIEWCONTROLLER I want that specific cell that I tapped in the HISTORYTABLEVIEWCONTROLLER to be marked PAID. I don't care how it gets marked I just want it done. Im using core data and I've already created a "paid" attribute. So I would also like the cell to be SAVED as PAID.
All help is appreciated, thanks in advance.
Sincerely, About to throw my iMac out the window
There a multiple ways you could accomplish this. One way is to pass both the managedObjectContext, and the selected managedObject to the detail controller. In the "Paid" button's action method, set the value of the "paid" attribute for that passed in object, and call save: on the managedObjectContext. As far as marking the cell, you should have that (a string "Paid" or whatever other kind of mark you want) tied to the value of the "paid" attribute, so once your database is updated, that should be reflected in the table view.
If you use core data, It will be quite simple to achieve this.
In your detail view, modify paid attribute in core data, and save.
In table view controller, observe NSManagedObjectContextObjectsDidChangeNotification notification. If core data changed, notification callback will get called. Then change the tableview's datasource and update table cell.

Filtering in UITableview

I am new to iOS app development.
I am developing an app which will show a list of companies.
This list is shown in a UITableviewController.
It has many labels like company name, their field in industry etc.
Once the list is displayed i want to give an option to filter based on their fields i.e.
listing all telecom industry or etc based on my login.
If the user is from a telecom industry i want to show all telecom related companies if user is from a service industry I want to show all service related industry and so on.
I want to give either a drop down on top or buttons or anything that will be easy to see and understand for the user to filter this out.
Please give me an ideas and if possible tutorials to achieve it.
Deeply appreciate your efforts,
Thanks
One way to do this, you can keep all the content in NSArray and you can put a set of buttons or a drop down list ( you can use NIDropDown) if you really want to have a professional look to categorize filters.
User will select any filter from the list and you need to filter the NSArray to extract the required information based on the action performed by the user on drop down list and reload the data in the UITableview.
follow these links to know how to create tables.
http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/
http://www.techotopia.com/index.php/Creating_a_Simple_iOS_5_iPhone_Table_View_Application
talking about filters , you can create two view controllers. On first you show all fileds that are present in a table view and user can select by tapping on anyone of them.
use delegate method tableView:didSelectRowAtIndexPath:. inside this method write the code to move to the next screen where details can be shown as per the user's selection.
tableView:didSelectRowAtIndexPath:
{
nextviewController = [secondDetailedView alloc]init];
[self.navigationcontroller pushviewcontroller: nextviewController Animated:Yes ];
}
now obviously you need a navigation controller that can be created in appdelegate method. What data has to be shown on next screen in table is up to you (on user's selection).

Assistance with Schedule App

I am currently constructing a School schedule app as a beginner project and I could use some help with the final steps. My app essentially consists of two tableview controllers. THe first table contains the student's block schedule (My Schedule). My schedule's table has a dictionary and has keys for each block the student could fill. The second contains a list of all the potential classes a student could take (Class List). All the courses in class list are stored across several arrays. If the student wants to edit their schedule they press an edit button on My Schedule, this produces a "Change" button on every cell in the schedule. What I would like is to create an IBAction that would register the key of the cell that was pressed. Then the app would go over to class list and display all the classes. The user would select a new course and the app would take that course and use it to replace the course in the block that was "changed".
I guess what I really need to know how to do is:
register which cell was chosen
programmatically segue between view controllers
replace a value in a dictionary for a particular key
I realize that this is a lot of info and I apologize if it is confusing or I did not provide enough information. If you would like to see some of my code or need some clarification I would be more than happy to give it.
You can trigger a UIViewController's segue by invoking
[self performSegueWithIdentifier:#"SomeSegueIdentifierProbablySetInIB" sender:self];

Need way to display iPhone addressbook contacts

I have been following many examples to add addressbook functionality to one of my views.
I am getting stumbled between Addressbook API, ABPeoplePickerNavigationController and how to fit them into UITableView. I am highly confused as to what all controls I need to put over my storyboard to get the whole thing working.
What I need is:
Last Name First Name (in table view display) along with an image icon (same for all contacts)
Phone Number (needed but not necessarily to be displayed)
When single cell is clicked, it should present a popover that offers certain number of options in a popup menu (but contacts table view should not disappear with the popover)
Can anyone point me exact example that achieves this?
XCode steps that can optionally achieve would also be highly appreciated.
I believe you are a little confused with how the AddressBook API works.
There's an apple developer reference that have a good example of how you can use the API.
I have linked it here Apple QuickContact Reference
In summary, you can preload certain data that you are keen to display on your tableview into NSArray. Then upon UITableView's didSelectRowAtIndexPath call the respective method to push the another viewcontroller to display.
Hope that clears up your doubt.

Resources