我在我的IOS应用程序中,我从服务器获取ID,我将其保存在字符串中,然后在NSMutableArray中添加字符串。我没有得到完美的方法,通过它我可以在数组中添加字符串并在外部使用数组范围。 这是我的代码请帮助我::
- (void)flickrAPIRequest:(OFFlickrAPIRequest *)inRequest didCompleteWithResponse:(NSDictionary *)inResponseDictionary
{
NSMutableArray *array=[[NSMutableArray alloc]init];
i=0;
NSLog(@"%s %@ %@", __PRETTY_FUNCTION__, inRequest.sessionInfo, inResponseDictionary);
if (inRequest.sessionInfo == kUploadImageStep)
{
snapPictureDescriptionLabel.text = @"Setting properties...";
NSLog(@"%@", inResponseDictionary);
NSString* photoID =[[inResponseDictionary valueForKeyPath:@"photoid"] textContent];
flickrRequest.sessionInfo = kSetImagePropertiesStep;
// for uploading pics on flickr we call this method
[flickrRequest callAPIMethodWithPOST:@"flickr.photos.setMeta" arguments:[NSDictionary dictionaryWithObjectsAndKeys:photoID, @"photo_id", @"PicBackMan", @"title", @"Uploaded from my iPhone/iPod Touch", @"description", nil]];
[self.array addObject:photoID];
arr=array[0];
counterflicker++;
NSLog(@" Count : %lu", (unsigned long)[array count]);
}
如何在数组中添加 photoID(字符串)? 请帮帮我..
最佳答案
在NSMutableArray中添加NSString是这样的
NSString *str = @"object";
NSMutableArray *loArr = [[NSMutableArray alloc] init];
[loArr addObject:str];
在你的代码中你为什么要使用 self.array ?就这样写吧。 [array addObject:photoID];
关于ios - 在 NSMutableArray 中添加字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23268880/