Friday 15 August 2014

uiviewcontroller - iOS - NSMutableDictionary reverting to previous state? -


I am trying to create a "delete" button on the "Edit Item" page, which can be reverted when pressed On the previous page, delete the related entry in a NSMutableDictionary , and then update the tableview list of entries.

It starts with an IBAction method on the "Edit Item" page, which is basically nothing but feeds the key to be removed from the back page controller:

  - (IBAction) deleteItem: (id) sender {[_parentController removeItemWithDeleteButton: [_ mainFactoidTextField text]]; }   

This is where the verb actually starts (on the list page):

  - Remove the (zero) item tag Del.button: (NSString * ) Key {[_currentItemsDict removeObjectForKey: key]; [Self. Navigation Controller PopWebControllerUnited: Yes]; }   

At the beginning of that method, there are 8 objects in the _currentItemsDict , which goes to removeObjectForKey: after 7. Then this is the ViewController above, which is the "edit item" page, returning us to the list of entries.

Then when that method is complete, the breakpoint immediately jumps on it: - (zero) VIEWWEAR APPLICATION: Animated {BOOL} {NSArray * tempArray = [ NSArray arrayWithArray: [_ currentItemsDeck allKeys]]; NSArray * SortedArray = [TempArray SortedArea Selector: @Selector (Case Insensitive Compaire :)]; _currentItemsArray = [with NSMutableArray array: sorted byre]; [_tableView reload data]; }

But from the first line of viewWillAppear: , _currentItemsDict is back in 8 objects. Since then everything works fine, but it is working with all the original 8 entries, which means that nothing was found.

From my limited experience with these types of things (I'm definitely still starting), I think that this is something to do with the popViewControllerAnimated: method , But I can not understand whether I have heard of some different variables in different ways which they can come back in the form of their own, but I have not wrapped my heart around this concept Or maybe it's completely something else, I I do not know. I can tell that _currentItemDict has 7 objects, and then one row later it comes 8 times.

Can a new man help and tell where I am going wrong? Or if this is easy, can you recommend a better solution for removing an entry in a NSMutableDictionary from a different ViewController? (Code samples and tutorial links are appreciated because I am currently not only sufficient, sometimes unable to translate my theory into theory!)

Thank you in advance for your help !

Do you know how the property works in C-2.0? I will declare a property in my parents view controller to include my _currentItemsArray declared as a strong reference. ;

In addition, set up a weak asset in your childViewController (which you want to delete)

  @property (nonatomic, weak) NSMutableArray * parentItemsArray;   

Set property on childViewController at push

  childViewController.parentItemsArray = self._currentItemsArray; [Self. Navigation controller Push ViewController: animated childViewController: Yes];   

Instead of calling a method on your original controller, remove the item within the childViewController within the array

  [self.parentItemsArray removeObjectAtIndex: indexOfKey];   

By doing this, you do not need to sort the array again to see. WillAppear Instead, just ask to reload the tableView

Any meaning

It may also be wise to include your logic inside the CellForAraetIndApath, the NumberofForce Insight and other tableview data source methods.

No comments:

Post a Comment