40media How to assign copy of object back to original reference?


How to assign copy of object back to original reference?



I have application with following design: Table View that lists documents. And ViewController where document is edited.

When editing the document I want to use a copy of object so in case user press Cancel I just throw away the copy. If user selected Save I copy modified document to original. (I can't have all document's fields as properties in viewController because there are too many of them).

Table View controller:

SelectedRowAtIndex {   document= [documentsArray objectAtIndex:indexPath.row];   viewController.assignedDocuemnt= document; } 

Then I have View controller class where the item is modified:

@interface @property (nonatomic,retain) Document *asignedDocument; @property (nonatomic,retain) Document *editedDocument;  viewDidLoad{    editedDocument= [assignedDocuemnt copy]; }   IBAction save {    assignedDocument=editedDocument; } 

My problem is that original document in documentsArray is not updated with edited version. What did I miss?


iPhone PHP integration

1:

does using try catch block in xcode show error on real device?
You're copying the value and then assigning the reference of the copy back over a reference to the original. for- loop in background thread accesses each index more than once — iPhone devThat's definitely not going to work.. Update coordinate property of MKAnnotation on parent viewcontroller after Touch End event? First, keep track of which document they're adding in the table view's viewcontroller.. Memory Management Question in Objective C Then add a handler for replacing the selected document with ananother to the table view's viewcontroller:. UITableView frame height animation glitch
- (void)replaceSelectedDocument:(Document*)newDoc {     [documents replaceObjectAtIndex: editingIndex                          withObject: newDoc]; } 
To save, call the table view controller's new message from the editor view controller with any thing like:. Should a property list be managed by its own model object?
[tableViewController replaceSelectedDocument: editedDocument]; 
A better way to did this would be to modify your editor view controller to take a tarreceive and action instead of calling back to the table view controller explicitly. How to remove NSString Related Memory Leaks?When you want to save, call the action:.
[tarreceive  performSelector: action withObject: editedDocument]; 
But that's ananother bump on the learning curve this you probably don't need to receive over today..


74 out of 100 based on 59 user ratings 1084 reviews