Deleting data from a table view

I have a data source that is in dictionary form (for why, see here). I have the following code that gets called in the commitEditing method for the table view:
- (void)removeObjectFromListAtIndex:(NSIndexPath *)indexPath {
NSMutableDictionary *mutableDataDictionary = [[NSMutableDictionary alloc] initWithDictionary:[listContent mutableCopy]];
dNSLog (@"listContent: %@, mutableDataDictionary: %@", listContent, mutableDataDictionary);
dNSLog (@"indexPath.section is %d", indexPath.section);
NSString *section = [[NSString alloc] init];
switch (indexPath.section) {
case 0:
dNSLog (@"Case Zero");
section = @"A";
break;
case 1:
dNSLog (@"Case One");
section = @"B";
break;
case 2:
section = @"C";
break;
case 3:
section = @"D";
break;
case 4:
section = @"E";
break;
case 5:
section = @"F";
break;
case 6:
section = @"G";
break;
case 7:
section = @"H";
break;
case 8:
section = @"I";
break;
case 9:
section = @"J";
break;
case 10:
section = @"K";
break;
case 11:
section = @"L";
break;
case 12:
section = @"M";
break;
case 13:
section = @"N";
break;
case 14:
section = @"O";
break;
case 15:
section = @"P";
break;
case 16:
section = @"Q";
break;
case 17:
section = @"R";
break;
case 18:
section = @"S";
break;
case 19:
section = @"T";
break;
case 20:
section = @"U";
break;
case 21:
section = @"V";
break;
case 22:
section = @"W";
break;
case 23:
section = @"X";
break;
case 24:
section = @"Y";
break;
case 25:
section = @"Z";
break;
default:
dNSLog (@"Default");
section = nil;
break;
if (mutableDataDictionary) {
NSMutableArray *arrayForNameSection = [[[NSMutableArray alloc] initWithArray:[mutableDataDictionary objectForKey:section]] mutableCopy];
[arrayForNameSection removeObjectAtIndex:indexPath.row];
NSArray *array = [[NSArray alloc] initWithArray:arrayForNameSection];
[mutableDataDictionary setObject:array forKey:section];
listContent = [NSDictionary dictionaryWithDictionary:mutableDataDictionary];
[array release];
[arrayForNameSection release];
[section release];
[mutableDataDictionary release];
The code works flawlessly the first time through, but when I try to delete a second item, it crashes with a CALayer exception involving copyWithZone. The analyzer in Xcode (3.2) is telling me something's going on with the NSString section, but I'm not sure what...I'd appreciate any help!
BTW, Ray if you happen to get this, the code is identical to what I emailed you, except that I added this code. The method name is the same.

I have a data source that is in dictionary form (for why, see here). I have the following code that gets called in the commitEditing method for the table view:
- (void)removeObjectFromListAtIndex:(NSIndexPath *)indexPath {
NSMutableDictionary *mutableDataDictionary = [[NSMutableDictionary alloc] initWithDictionary:[listContent mutableCopy]];
// What happens to the mutableCopy? Looks like a leak.
dNSLog (@"listContent: %@, mutableDataDictionary: %@", listContent, mutableDataDictionary);
dNSLog (@"indexPath.section is %d", indexPath.section);
NSString *section = [[NSString alloc] init];
// Memory leak because in all cases you re-assign the variable.
// Arrrgggg!
NSString * section = nil;
if((indexPath.section >= 0) || (indexPath.section < 26))
section = [NSString stringWithFormat: @"%c", 'A' + indexPath.section];
switch (indexPath.section) {
case 0:
dNSLog (@"Case Zero");
section = @"A";
break;
case 1:
dNSLog (@"Case One");
section = @"B";
break;
case 2:
section = @"C";
break;
case 3:
section = @"D";
break;
case 4:
section = @"E";
break;
case 5:
section = @"F";
break;
case 6:
section = @"G";
break;
case 7:
section = @"H";
break;
case 8:
section = @"I";
break;
case 9:
section = @"J";
break;
case 10:
section = @"K";
break;
case 11:
section = @"L";
break;
case 12:
section = @"M";
break;
case 13:
section = @"N";
break;
case 14:
section = @"O";
break;
case 15:
section = @"P";
break;
case 16:
section = @"Q";
break;
case 17:
section = @"R";
break;
case 18:
section = @"S";
break;
case 19:
section = @"T";
break;
case 20:
section = @"U";
break;
case 21:
section = @"V";
break;
case 22:
section = @"W";
break;
case 23:
section = @"X";
break;
case 24:
section = @"Y";
break;
case 25:
section = @"Z";
break;
default:
dNSLog (@"Default");
section = nil;
break;
if (mutableDataDictionary) {
NSMutableArray *arrayForNameSection = [[[NSMutableArray alloc] initWithArray:[mutableDataDictionary objectForKey:section]] mutableCopy];
// Get rid of this copy too.
[arrayForNameSection removeObjectAtIndex:indexPath.row];
NSArray *array = [[NSArray alloc] initWithArray:arrayForNameSection];
[mutableDataDictionary setObject:array forKey:section];
listContent = [NSDictionary dictionaryWithDictionary:mutableDataDictionary];
// This is autoreleased. You might want to retain it.
[array release];
[arrayForNameSection release];
[section release];
[mutableDataDictionary release];

Similar Messages

  • Send data from 2 table view to a RFC

    Hi All,
    What I try to do is following:
    I have two table view A and B, which contain data, which I need both for the RFC. Now I can Toolbar for one of the tables and connect both tables to the RFC, both with the action caused by the button.
    But only the data from the table view with the button is sent to the RFC.
    Has anyone an idea what I could do?
    BR Matthias

    Hi Matthias,
    have you defined an action like 'submit' and declared the events in the transition like '*submit'?
    Best Regards,
    Marcel

  • Deleting data from a table where there are no indexes on the table

    Hi
    We have one interface program for one time process.When I was testing the process it was taking too much time to load the data around 1000 records.
    it happens in 2 steps
    1 puts into stage table
    2 puts into base table
    in the process/package I have delete statement that deletes data from stage table before each process.
    Stage table did not have any indexes but the base table has(obvisiosly)
    any idea?
    please help me on this.
    Thanks,
    Y

    Hi,
    Please post the application/database details along with the OS.
    Is this interface program a seeded or custom one?
    Please enable trace on this concurrent program as per (Note: 296559.1 - FAQ: Common Tracing Techniques within the Oracle Applications 11i/R12) and generate the TKPROF to find out why it takes that long to load/delete the data.
    Thanks,
    Hussein

  • Deleting data from SID Table

    Hi,
    I have deleted master data of an info object but it does not remove all the data from the SID table.
    I have selected with SID's option but not all data was removed.
    I am getting the error below when transporting
    "SID Table /BIC/ S2QKHITIND Contains Data : Characteristic ZQKHITIND Cannot be activated. "
    What needs to be done to get the charecteristic activated.
    Thanks
    James

    Hi Selva,
    Thank you for the info. I have deleted data from all the infoproviders but still get the message
    The system is unable to delete all the master data as, because some of it is still in use.  (See log:
    Object RSDMD, sub-object MD_DEL )
    Do you want to delete the data records that are no longer in use?
    What does this mean. is it due to the query open in some place or something else.
    While I am not able to delete the SID table entries as the delete is not active. Please help.
    Thanks
    James

  • Deleting data from EDPAR table

    hi  everyone,
                               I need to delete data forom table EDPAR. two conditions are there. Once through first radio button in selection screen based on values of kunnr selected from select options. In the second case. if i select the second radio button, all data from EDPAR table gets deleted.
    Can any one offer me proper CODE  to do it....Pls help.

    SAP delivers a standard transaction to edit the contents of this table, VOE4, this is safer then using a custom code to delete rows from the table.

  • Deleting data from another table with multiple conditions

    Hi frnds
    I need to delete some data from a table based on multiple condition I tried following sql but its deleteing some rows which is not meeting the criteria which is really dangerours. When i trying = operator it returns ORa- 01427 single -row subquery returns more than one row
    delete from GL_TXNS
    where TRN_DT in (Select trn_Dt from GL_MAT)
    and BR in (select ac_branch from GL_MAT)
    and CODE in (select CODE T from GL_MAT)
    and (lcy_amt in (select lcy_amt from GL_MAT) or
    fcy_amt in(select fcy_amt from GL_MAT)
    rgds
    ramya

    My answer is the same as Avinash's but I will explain a little bit more.
    ORa- 01427 single -row subquery returns more than one rowmeans that you have a subquery that Oracle is expecting one value from that is returning multiple values. In your case you need one value for the equijoin ("=") and you are getting more than one value back. The error happens even if all the values are the same - multiple values being returned will cause the error.
    The solution is to either allow multiple values to be returned (say, use the IN condition istead of "=") or only return one value if possible (say, forcing one value by using DISTINCT, GROUP BY, or a WHERE clause condition of ROWNUM=1) - but these workarounds must be checked carefully to make sure they work correctkly

  • Deleting Data from 85 tables

    Hi All,
    There is a 13 years old data in DB, which holds data from 2001. The task assigned to me is to delete the old data from Main table and its associated tables.
    87 tables are identified and data needs to be removed.
    1) We don't have an option to bring down the DB, the DB should be online.
    2) We can't disable triggers and constratins.
    3) We can't disable LOGGING
    4) The total Size of the tables that we are going to do the deleting is around 290 GB.
    5) DB is Oracle 11g.
    What I did is,
    I wrote a Stored Procedure, that get's MONTH and YEAR as input parameter. This procedure is called 12 times to delete one year.
    I have collected all the ID’s and stored in a separate table. Based on the id, I am deleting the data from each table and committing. (I was doing a bulk commit after deleting some group of tables, but those commits took lot of time.).
    Now total time to delete 150 Million Rows from the entire table is 4 days to delete 7 years of data.
    Is it any way I can make the process faster other than adding INDEX to avoid full table scans.
    is there is a better approach to handle this?.
    Advance Thanks for your response.
    -Jac

    988197 wrote:
    Hi All,
    There is a 13 years old data in DB, which holds data from 2001. The task assigned to me is to delete the old data from Main table and its associated tables.
    87 tables are identified and data needs to be removed.
    1) We don't have an option to bring down the DB, the DB should be online.
    2) We can't disable triggers and constratins.
    3) We can't disable LOGGING
    4) The total Size of the tables that we are going to do the deleting is around 290 GB.
    5) DB is Oracle 11g.
    What I did is,
    I wrote a Stored Procedure, that get's MONTH and YEAR as input parameter. This procedure is called 12 times to delete one year.
    I have collected all the ID’s and stored in a separate table. Based on the id, I am deleting the data from each table and committing. (I was doing a bulk commit after deleting some group of tables, but those commits took lot of time.).
    Now total time to delete 150 Million Rows from the entire table is 4 days to delete 7 years of data.
    Is it any way I can make the process faster other than adding INDEX to avoid full table scans.
    If you added another index, that would likely make the operation SLOWER because every time a row is deleted, the index would also have to be changed to reflect that fact. Indexes introduce more work to be done on DML operations.
    RP0428 has it right. This is a one-time operation and you are already well down the road. Just keep going.
    is there is a better approach to handle this?.
    Advance Thanks for your response.
    -Jac

  • Is there a restriction on deleting data from an table through a view?

    I have an Oracle Forms application where, try as I might, I cannot delete records based on a view. I know that the restriction may be because of Forms but, is there a database level restriction on deleting records through a view?

    try as I might, I cannot delete records based on a view. Do you get an error?
    There are several restrictions about deleting via a view:
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1191

  • How to delete data from the table PA0007

    Hi Friends,
    Thank you for your kindly help.
    When I upload data to infotype 0007(planed working time),
    there is something wrong with the infotype 2011. So I want
    to delete the data of  infotype 0007. While using the program RPUREOPN to delete the data, the system will say:0007 cannot be deleted because of time constraint 1/A.
    Now how can I delete the data from table PA0007?
    Pls help me urgently.
    Best wishes
    Anne

    Hi Sikindar,
       Thank you for your help.
      There is another question. There are five clients (Client 300,310,320,330,350) in my HR DEV system. I just want to delete the data of infotype 0007 in client 350. When I change the the time constraint and delete the data in client 350, the data of infotype 0007 in other clients will be safe or not?
    Thank you again for your help!
    Best wishes
    Anne

  • Deleting data from two tables

    The data is migrated to our production database by accident and I would like to delete those records by using the created date and created by. this information is exits in two tables and I am wondering what i need to do to
    delete the records from both tables. refvendor is the main table. please help.
    SELECT *
    FROM refvendor v, refvendoraddress a
    WHERE v.refvendor_id = a.refvendor_id
    AND v.createdby = 'Migration'
    AND TRUNC (v.created_dt) = TO_DATE ('5/4/2010', 'MM/DD/YYYY')

    You can set the foreign key on: on delete cascade;
    example:
    SQL> create table refvendor (refvendor_id number);
    Table created.
    SQL> alter table refvendor add primary key (refvendor_id);
    Table altered.
    SQL> create table refvendoraddress (refvendor_id number);
    Table created.
    SQL> alter table refvendoraddress add constraint refvendoraddress_r01 foreign key (refvendor_id)
      2  references refvendor (refvendor_id) on delete cascade;
    Table altered.
    SQL> insert into refvendor values (1);
    1 row created.
    SQL> insert into refvendor values (2);
    1 row created.
    SQL> insert into refvendor values (3);
    1 row created.
    SQL> insert into refvendor values (4);
    1 row created.
    SQL> insert into refvendor values (5);
    1 row created.
    SQL> insert into refvendoraddress values (1);
    1 row created.
    SQL> insert into refvendoraddress values (2);
    1 row created.
    SQL> insert into refvendoraddress values (3);
    1 row created.
    SQL> insert into refvendoraddress values (4);
    1 row created.
    SQL> insert into refvendoraddress values (5);
    1 row created.
    SQL> delete from refvendor where refvendor_id > 3;
    2 rows deleted.
    SQL> select count(*) from refvendor;
      COUNT(*)                                                                     
             3                                                                     
    SQL> select count(*) from refvendoraddress;
      COUNT(*)                                                                     
             3                                                                      L.

  • Delete data from Q table of the master data

    Hi ,
    I had incorrect data loaded into the master data table of a particular object.
    Upon repairing info object, the incorrect data got deleted from all the tables of the object except from the Q table.
    After running repair multiple times also, these records in Q table are not getting deleted.
    HOw can i delete these records from the Q table of the object ?
    Thanks,
    Tapish

    Hi Tapish,
    Are you able to identify the records in RSD1 --> Maintain?  You should be able to delete them from there.
    Best Regards,
    Vincent

  • Deleting Datas from a table without disabling constraints.

    Hi,
    I am working in Oracle9i and solaris 5.8. In that i want to delete half of the datas in a table . the table contains one lakh rows but i need to delete only 50 thousand rows. But the table is constraints enabled.Please send me some queries how to delete the datas withput disabling the constraints.

    What type of constraint do you have ?
    In case of not null, unique, primary key constraint you can delete the rows without disabling the constraints.
    In case of referential integrity constraint you can also delete the rows without disable the constraints but you have to specify on delete cascade constraints clause. By doing so, Oracle will delete the rows in the child table as well.
    http://www.techonthenet.com/oracle/foreign_keys/foreign_delete.php

  • Need to delete data from main table and all child tables ...

    hi all,
    i need to delete rows pertaining to perticular table and all the child
    tables basing on certain code.i need to write a procedure to which i will
    pass the table name and code..
    like del_info(tab_name,code)
    example:
    suppose if i call as del_info(clients,760)
    the procedure should delete all info reg. code 760
    and the table clients and also all the child records of this table
    perting to code 760.
    simply .. i need to delete from the table passed and also
    all the child tables down the heirarchy regarding certain code ...
    help ???
    Ravi Kumar M

    Hi,
    Depends how you defined referential integrity.
    You can use ON DELETE CASCADE, please read the next doc http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/clauses3a.htm#1002692
    Hope this help you,
    Nicolas.

  • Best way to pass back data from hierarchical table view?

    Hi,
    I have a view hierarchy using a navigation controller that's working pretty well. One of the bottom level views is a table view where the user selects an item from the list. This bottom view checks the list item, saves the selected item in a property, and then pops the view off the stack.
    What's the best way to alert the parent view that the child view has been popped off so it can retrieve the value in the property? The calling push returns immediately, so it doesn't appear to be a modal call. I want to be able to use the same controller from other parent forms, so I need to be able to do this without referencing the parent in the child form ideally.
    Thanks
    Ray

    Hi, well let me try to explain it a bit more
    - Add a "delegate" property to your child-viewcontroller-class
    - Define a protocoll within each chil-viewController-class
    In this example let us name it "didSelectValue:(NSString *)value"
    - In the parent-viewcontroller before pushing a child-viewcontroller set it's delegate property to "self" (parent-viewcontroller)
    - In the parent-viewcontroller implement to protocoll-method "didSelectValue:(NSTring *)value"
    - In the child view-controller in (assuming it is a tableViewcontroller) add some code in didSelectRowAtIndexPath that checks if the delegate is set and check if it responds to selector "didSelectValue:(NSString *)value". If so, call it with the selected value.

  • Delete data from internal table

    Hi Experts...
    I have output like :
    erdat           matnr
    12/2/2007    100000
    13/2/2007    100000
    14/11/2007  100001
    14/6/2007    100001
    but i want it like:
    erdat                 matnr
    13/2/2007     100000
    14/6/2007     100001
    data retriving from table direct..
    and it is not working with max function.
    plz help me..

    Hi,
    You can do as below:
    Sort itab by erdat matnr descending.
    delete adjacent duplicates frommiab comparing erdat.
    Thanks,
    Sriram Ponna.

Maybe you are looking for