nsarray

Sorting NSMutableArray using SortDescriptor AND Predicate possible?

偶尔善良 提交于 2019-12-30 03:27:08
问题 I have an array of type "Restaurant" which has an NSSet of "Rating." Rating has an ID and a value. I want to sort the array of Restaurant's by rating with an ID of 01, from high to low. Something like the following, but how do I use the predicate and sort descriptor together on originalArray? NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Rating.rating_id=%d", ratingID]; NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"currentValue" ascending:YES]; NSArray

NSDictionary value replacing instead of adding in Plist

北城以北 提交于 2019-12-29 08:09:14
问题 hi i tried to add values(book id,page number,notes) from NSdictionary to Plist but each time the new value replacing the previous one?but i need all values in plist my code for adding dictionary to plist is NSString *bid=@"95"; NSString *pnum=@"12"; userNotes=[[NSMutableDictionary alloc]init]; [userNotes setValue:userNotesTextview.text forKey:@"notes"]; [userNotes setValue:bid forKey:@"bookid"]; [userNotes setValue:pnum forKey:@"pagenumber"]; userNotesView.hidden=YES; _background.hidden = YES

indexOfObject vs. indexOfObjectIdenticalTo

情到浓时终转凉″ 提交于 2019-12-29 04:27:05
问题 What is the difference between these two NSArray methods? 回答1: indexOfObjectIdenticalTo checks for the exact same id (same address). indexOfObject checks that isEqual: returns YES . 回答2: The first uses isEqual: to find a matching object, while the second looks for the same object (i.e., the object at the same memory location). 回答3: indexOfObjectIdenticalTo is far more faster than indexOfObject but it uses pointer comparison == instead of calling isEqual: If you are searching for a pointer

Alphabetical sections in table table view in swift

自古美人都是妖i 提交于 2019-12-28 04:01:10
问题 I have a list of names sorted alphabetically, and now I want display these names in a table view. I'm struggling with grouping these names for each letter. My code looks like this: let sections:Array<AnyObject> = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] var usernames = [String]() func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let cellID = "cell" let cell: UITableViewCell

how to select the images differently from array using objective-c

折月煮酒 提交于 2019-12-26 02:42:36
问题 I have store 10 images in NSArray. In UIViewController i placed 6 UIImageView,and given the outlet in .h file. I need to select any 6 images from the array how to do? And need to display the images in UIImageView. - (void)viewDidLoad { [super viewDidLoad]; images=[[NSMutableArray alloc]initWithObjects:[UIImage imageNamed:@"Navarre-Family-Eye-Care-Navarre-Florida-Optometrist-Santa-Christmas-Toy-Safety.jpg"],[UIImage imageNamed:@"Christmas-Wallpapers-HD-Picture.jpg"],[UIImage imageNamed:@

Using NScanner to parse CSV File to Dictionary Array [duplicate]

帅比萌擦擦* 提交于 2019-12-25 19:03:47
问题 This question already has answers here : Create a Custom Formatted Dictionary Array from CSV File of Data (3 answers) Closed 6 years ago . I've created an iPhone app that has a dictionary array of locations (lat,long,point). I created the array by manually entering each value. myLocationArray = @[ @{ kStation : @"1", kLatitude : @( 41.656467), kLongitude : @(-81.277963) }, @{ kStation : @"2", kLatitude : @(41.657118), kLongitude : @(-81.276545) }, @{ kStation : @"3", kLatitude : @(41.658493),

send array of images with AFNetworkin ios

≯℡__Kan透↙ 提交于 2019-12-25 18:43:46
问题 I have an example, where I send image and parameters to server. But I need to send NSArray of images.How can I do this? NSData *imageToUpload = UIImageJPEGRepresentation(uploadedImgView.image, 1.0);//(uploadedImgView.image); if (imageToUpload) { NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys:keyParameter, @"keyName", nil]; AFHTTPClient *client= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://------"]]; NSMutableURLRequest *request = [client

NSArray of NSRegularExpressions in swift

a 夏天 提交于 2019-12-25 18:21:09
问题 The fork here has a custom link function but the implementation in the actual code is in objective C.This is the code line and her it is printed again: - (NSArray<NSRegularExpression*>*)getRegularExpressions { return [NSArray arrayWithObject:[NSRegularExpression regularExpressionWithPattern:@"#([a-zA-Z0-9])+" options:0 error:NULL]]; } I was wondering how i could reproduce this in swift, I have already placed all of the framework code, I just need to know how to do this. 回答1: Try this func

Unwrap array of dictionary

泄露秘密 提交于 2019-12-25 17:10:10
问题 I have an array of dictionary from firebase like bellow : "gcm.notification.data" = "{\"request\":\"update_location\",\"latitude\":\"45.48945419494574\",\"customMessage\":{\"loc-args\":[\"iPhone di Tester\"],\"loc-key\":\"LOCATION_CHECKIN\"},\"type\":\"checkin\",\"message\":\"Ggg\",\"longitude\":\"9.195329826333742\",\"child\":{\"name\":\"iPhone di Tester\",\"pid\":\"C312EDDC-E8A8-4EFC-9E65-957BE5DAC5FC\"}}"; I tried to unwrap the request, like bellow but it crash, can anyone help.

Equivalent for “stringByDeletingPathExtension ” for an array

我们两清 提交于 2019-12-25 12:05:25
问题 I want to run stringByDeletingPathExtension for all NSString members of an NSArray. How can I do this in Objective-C? 回答1: NSArray *myArray = ... ; [myArray makeObjectsPerformSelector:@selector(stringByDeletingPathExtension)]; EDIT : As @Wevah pointed out in the comments, this solution does not solve the problem, since stringByDeletingPathExtension returns a string rather than modified the object on which is invoked. NSMutableArray *newArray = [[[NSMutableArray alloc] initWithArray:myArray]