Wednesday, 23 June 2010

appending objectForKey title after changing it with user input


i saving nsmutablearray different objectsforkeys.
having 3 of object set input user.
able append new object text .caf , .txt. when these called in next viewcontroller can recognized , used.

here code:

code:
- (void)saveaction:(id)sender {            [self.nametextfield resignfirstresponder];      [self.imagenametextfield resignfirstresponder];            nsmutabledictionary *dictionary = [nsmutabledictionary dictionarywithobjectsandkeys:                                                                                                                           @"main.caf",@"pictureaudiokey",                                         @"audio1.m4a",@"firstaudiokey",                                         @"audio2.m4a",@"secondaudiokey",                                         @"audio3.m4a",@"thirdaudiokey",                                         @"audio4.m4a",@"fourthaudiokey",                                         @"audio5.m4a",@"fifthaudiokey",                                         @"audio6.m4a",@"sixthaudiokey",                                         @"main.jpg",@"photoimagekey",                                         @"some.txt", @"identity",                                          @"imagename.txt",@"numberkey",nil];     //here change object values user puts   textfield imagename.text   works fine photo since recognized png without extension , loaded       [dictionary setobject:[[self imagenametextfield]text]                     forkey:@"photoimagekey"];  //however when strip .txt text file...or .caf audio //file not recognized , not loaded.      [dictionary setobject:[[self imagenametextfield]text]                     forkey:@"identity"];  //i tried  //identity=[identity stringbyappendingformat:@"txt" didn't work        nsstring *audiostring = [dictionary objectforkey:@"pictureaudiokey"];      audiostring = [audiostring stringbyappendingformat:@".caf"];      [dictionary setobject:[[self imagenametextfield]text]                     forkey:@"pictureaudiokey"];  
does have suggestions?
 

you post isn't making sense me.

first sentence wrong "nsmutablearray".

mention 3 objects, looks creating 1 input field, kind of question need that.

mention want append dictionary, in fact overriding values 3 keys pictureaudiokey, photoimagekey, , identity. if code looks this, don't bother adding values begin with, or actual append using different key names.

set initial value photoimagekey .jpg extension later mention not using extension file load .png. make mind using.

unless user typed in extension, code suggests shouldn't, should appending .caf , .txt input result before appending or altering dictionary.

in last few lines of code, extracting value of pictureaudiokey, "main.caf", altering adding .caf, , doing nothing result. expect result of alteration "main.caf.caf".

think might want lines this;
code:
  [dictionary setobject:[[[self imagenametextfield] text] stringbyappendingformat:@".txt"] forkey:@"identity"];  [dictionary setobject:[[[self imagenametextfield] text] stringbyappendingformat:@".caf"] forkey:@"pictureaudiokey"];  [dictionary setobject:[[[self imagenametextfield] text] stringbyappendingformat:@".jpg"] forkey:@"photoimagekey"];  
i'll again, if want append values, need new key names because these overwrite values initialized keys.

since see no retains or releases assuming using arc. biggest hint use of class method dictionarywithobjectsandkeys: returns non-retained object. believe arc retain you.

oh, have declared dictionary local variable, how getting next view controller or otherwise saving it?

code incomplete , makes difficult others you.
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment