ios - Multiple methods named "setLength" found -
i have code:
[[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] setlength:0];
and repeated 3 times
#pragma mark myurlconnection delegate methods - (void)connection:(myurlconnection *)connection didreceiveresponse:(nsurlresponse *)response { nslog(@"response received..."); [[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] setlength:0]; } - (void)connection:(myurlconnection *)connection didreceivedata:(nsdata *)data { nslog(@"receiving data..."); [[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] appenddata:data]; } - (void)connectiondidfinishloading:(myurlconnection *)connection { [[uiapplication sharedapplication] setnetworkactivityindicatorvisible:no]; nslog(@"request succeeded! received %d bytes of data",[[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] length]); //do data nsstring *response = [[nsstring alloc] initwithdata:[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] encoding:nsasciistringencoding]; nslog(@"http response: %@",response); if(connection.tag == apnregisterurlconnection) { if([response isequaltostring:kpushnotificationregistrationsuccess]) [self.usernotifications setobject:[nsnumber numberwithbool:true] forkey:kregistered]; else if ([response isequaltostring:kpushnotificationreregistrationsuccess]){ [self.usernotifications setobject:[nsnumber numberwithbool:true] forkey:kregistered]; nsuuid *udid = [[uidevice currentdevice] identifierforvendor]; nsstring *httpbody = [nsstring stringwithformat:@"udid=%@",udid]; nsstring *url = [krequesturladdress stringbyappendingstring:@"updatenotifications.php"]; [self postrequestforurl:url withparameters:httpbody andtag:updatenotificationsurlconnection andpassingdata:nil andoptionalmethod:@selector(displayuiactivityindicatorview)]; } else { [self alertwithtitle:@"error configuring push notifications" andmessage:kunknownerroralertmessage]; } } else if(connection.tag == addnotificationurlconnection) { if([response isequaltostring:kpushnotificationadditionsuccess]){ [[self.usernotifications valueforkey:knotifications] addobject:connection.passingdata]; [self.tableview reloadsections:[nsindexset indexsetwithindex:0] withrowanimation:uitableviewrowanimationnone]; } else { [self alertwithtitle:@"error adding notification" andmessage:kunknownerroralertmessage]; } } else if(connection.tag == deletenotificationurlconnection) { if([response isequaltostring:kpushnotificationdeletionsuccess]){ [[self.usernotifications valueforkey:knotifications] removeobjectatindex:[connection.passingdata row]]; [self.tableview deleterowsatindexpaths:[nsarray arraywithobject:connection.passingdata] withrowanimation:uitableviewrowanimationfade]; } else { [self alertwithtitle:@"error deleting notification" andmessage:kunknownerroralertmessage]; } } else if(connection.tag == updatenotificationsurlconnection) { if(![response isequaltostring:@"error selecting udid"]){ //load notifications myurlconnection, since internet required add items locally, logical sync syncing match database //sample format list of notifications // (int)periodindex (int)timeindex|(int)periodindex2 (int)timeindex2|(int)periodindex3 (int)timeindex3 (sorted period index // i.e. --> 0 13|2 6|4 11|4 6|9 4 nsarray *unparsednotifications = [response componentsseparatedbystring:knotificationdelimeter]; nsmutablearray *parsednotifications = [nsmutablearray arraywithcapacity:[unparsednotifications count]]; int x; if(!([[unparsednotifications objectatindex:0] isequaltostring:@""] && [unparsednotifications count] == 1)) {//no hits in database nsarray *notificationstringarray; notification *parsed; (x=0; x<[unparsednotifications count]; x++) { notificationstringarray = [[unparsednotifications objectatindex:x] componentsseparatedbystring:kelementdelimeter]; parsed = [notification withperiod:[[notificationstringarray objectatindex:0] intvalue] andtime:[[notificationstringarray objectatindex:1] intvalue]]; [parsednotifications addobject:parsed]; } nslog(@"number of notifications in database = %d",[parsednotifications count]); } //add missing notifications array notification *value; for(x=0;x<[parsednotifications count];x++){ value = [parsednotifications objectatindex:x]; if(![[self.usernotifications valueforkey:knotifications] containsobject:value]){ [[self.usernotifications valueforkey:knotifications] addobject:value]; nslog(@"adding notification period:%@ , time:%@",[value periodstring],[value timestring]); } } //delete objects in local array missing online, reversed in order remove largest indices , rows issue not arise looping through array has been changed for(x=[[self.usernotifications valueforkey:knotifications] count]-1;x>=0;x--){ value = [[self.usernotifications valueforkey:knotifications] objectatindex:x]; if(![parsednotifications containsobject:value]){ nslog(@"deleting notification period:%@ , time:%@",[value periodstring],[value timestring]); [[self.usernotifications valueforkey:knotifications] removeobjectatindex:x]; } } [self.tableview reloadsections:[nsindexset indexsetwithindex:0] withrowanimation:uitableviewrowanimationnone]; } else [self alertwithtitle:kdefaultalerttitle andmessage:kunknownerroralertmessage]; } [self cleanupafterrequest:connection.tag]; [response release]; [connection release]; [[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] setlength:0]; } -(void)cleanupafterrequest:(int)connectiontype{ if(connectiontype == addnotificationurlconnection){ self.tableview.allowsselection = true; self.tableview.allowsselectionduringediting = true; } else if(connectiontype == deletenotificationurlconnection){ self.view.userinteractionenabled = true; } else if(connectiontype == updatenotificationsurlconnection){ [[self.view viewwithtag:5] removefromsuperview]; } } - (void)connection:(myurlconnection *)connection didfailwitherror:(nserror *)error { [[uiapplication sharedapplication] setnetworkactivityindicatorvisible:no]; nsstring *failingkey = nil; //if_pre_ios4(failingkey = nserrorfailingurlstringkey;); failingkey = nsurlerrorfailingurlstringerrorkey; nslog(@"connection failed! error - %@ %@", [error localizeddescription], [[error userinfo] objectforkey:failingkey]); [self cleanupafterrequest:connection.tag]; [self alertwithtitle:kdefaultalerttitle andmessage:kdefaultalertmessage]; [connection release]; [[self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]] setlength:0]; }
xcode returns error "multiple methods named "setlength" found."
any ideas on should fix it?
assign results of [self.receiveddata objectforkey:[nsnumber numberwithint:connection.tag]]
variable of proper type. call setlength:
method on variable.
btw - use modern syntax:
self.receiveddata[@(connection.tag)];
the @(connection.tag)
replaces use of [nsnumber numberwithint:connection.tag]
, self.receiveddata[xxx]
replaces use of objectforkey:
.
Comments
Post a Comment