nsarray

populating Tableview with a function that uses SwiftyJSON

霸气de小男生 提交于 2019-12-11 15:06:03
问题 I have a function that returns parsed information out of a JSON string. var info = [AppModel]() func getEarthquakeInfo(completion: (results : NSArray?) ->Void ){ DataManager.getEarthquakeDataFromFileWithSuccess { (data) -> Void in let json = JSON(data: data) if let JsonArray = json.array { for appDict in JsonArray { var ids: String? = appDict["id"].stringValue var title: String? = appDict["title"].stringValue var time: String? = appDict["time"].stringValue var information = AppModel(idEarth:

Adding objects in array of app delegate from view controller in Objective-C iOS

妖精的绣舞 提交于 2019-12-11 14:14:10
问题 Help me in adding objects in array of app delegate from UIViewController in Objective-C I guess I am doing mistake, help me in this regard I want to add objects in array of app delegate from view controller in appdelegate.h @property (nonatomic, retain) NSMutableArray *sharedArray; in appdelegate.m @implementation AppDelegate @synthesize sharedArray; inside didfinishlaunching self.sharedArray = [[NSMutableArray alloc] init]; in ViewController @interface ViewController () { UIApplication

separate future date in nsmutablearray

匆匆过客 提交于 2019-12-11 13:11:42
问题 I am having a mutable array in that array i am having only past date, current date & future date. I have to separate the future date & store into another array. Can you help me. This is my array: uniqueItems( "2015-03-01", "2015-02-28", "2015-02-22", "2015-02-21", "2015-02-20", "2015-02-15", "2015-02-14", "2015-02-13", "2015-02-08", "2015-02-07", "2015-02-01", "2015-01-31", "2015-01-30", "2015-01-25", "2015-01-24", "2015-01-18", "2015-01-17", "2015-01-16", "2015-01-11", "2015-01-10", "2014-12

AFNetworking Array returns JSON inside of block but not outside of block [duplicate]

≡放荡痞女 提交于 2019-12-11 12:06:28
问题 This question already has an answer here : AFJSONRequestOperation array populates but cannot NSLog contents outside of success block (1 answer) Closed 5 years ago . I've created a custom method that returns JSON data using the AFNetworking API. I'm trying to store data pulled from my web service in an Array as JSON. NSLog(@"%@", json); inside the block prints the JSON data to console. Outside the block NSLog(@"%@", json); return null. Why is this and how can it be fixed? What I'm trying to do

Binary searching NSArray without having the object to search but a condition

蓝咒 提交于 2019-12-11 11:41:54
问题 So, I have this array of objects with NSNumber s in it. I have a number of my own and I need to find a number in the array that's greater than my number by least margin. How do I employ binary search for this? The method : indexOfObject:inSortedRange:options:usingComparator accepts the object as a parameter and I don't have it. How do I do the binary search with this condition but without an object? 回答1: You need to supply an object - any object specifying the value of the item being searched

Enumerate NSArray starting at givven index searching both ways (wrap around)

房东的猫 提交于 2019-12-11 10:32:47
问题 Example. I've got an array with 15 objects. I want to start enumerating from a given index. Say start at index 5 and then the index above, the index under, above, under etc... I do want it to wrap around. So the order of indexes in my example would be. 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0, 11, 14, 12, 13 It would be great to have a method signature similar to following line, but I don't require that to approva an answer: - (void)enumerateFromIndex:(NSUInteger)index wrapAroundAndGoBothWays:(void (

iOS sort one array based on order of strings in another array

▼魔方 西西 提交于 2019-12-11 09:47:42
问题 This is another very specific problem I am trying to solve. I am pulling a list a twitter user accounts logged into the users settings application. This returns an array with the usernames in the correct order. I then pass this array to this twitter API: https://api.twitter.com/1.1/users/lookup.json The returned array contain all the additional data I need for each user account logged in. The first array contains NSStrings (usernames), the returned array has been parsed to contain

Object filter crashes if no results can be found

瘦欲@ 提交于 2019-12-11 09:45:03
问题 I have written some code to find a user's favourites out of an array of custom objects. It works absolutely fine unless that object does not exist, in which case it just crashes. I was considering completely rewriting the code a different way, but I imagine there is probably a way to fix it... I just can't figure out how. Here is my code: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView

parsing json - reached max depth

梦想的初衷 提交于 2019-12-11 09:33:57
问题 I want to parse the comments of a reddit post with over 500 comments. For example this one: http://www.reddit.com/comments/xu11o The json url is: http://www.reddit.com/comments/xu11o.json In am using SBJson to achieve this. When I try to get a NSArray with this code: NSString* response = [request responseString]; NSArray* responseArray = [response JSONValue]; I get this error message: -JSONValue failed. Error is: Input depth exceeds max depth of 32 Changing the depth to a higher number of for

How to filter a NSArray of subviews by tag using NSPredicate?

本小妞迷上赌 提交于 2019-12-11 09:17:37
问题 I have this array of subViews: <UIButton: 0xa2b1600; frame = (41 20; 42 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0xa2b06e0>>, <UIButton: 0xa2b1290; frame = (121 694; 69 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0xa2b0dc0>>, <SequenceViews: 0xb16fba0; frame = (62 393; 280 323); tag = 100; gestureRecognizers = <NSArray: 0xb16dc90>; animations = { position=<CASpringAnimation: 0xb16c990>; }; layer = <CALayer: 0xb168880>>, <SequenceViews: 0xb171c30; frame = (62 52; 280