nsarray

How do you join an NSArray of [Number numberWithChar: c]'s into an NSString?

▼魔方 西西 提交于 2019-12-21 22:18:02
问题 When I use componentsJoinedByString , I just get a long string of digits. Edit: I realize this task is confusing. Why on earth would anyone populate an NSArray with NSNumbers if they wanted an NSString? The answer is that I'm writing an extensible unit test framework. The basic functions genNum , genBool , and genChar generate NSNumbers with random int, BOOL, and char values respectively. Then there's genArray which generates a random array using a specified generator. So to construct a

iPhone/iOS How to load a lot of image in many folder and show in a table view?

空扰寡人 提交于 2019-12-21 20:19:26
问题 I got annoying question... What if I have many image , and I want load it in to a table view And show the file name as cell's text , and the preview image is also show in the cell. When I select the cell , it will push to next view , show the big size image. That's it . I don't know how to load many folder to an array? /*********** EDIT ***********/ This is the folder I set many images inside You can see that's only one root folder ... And this is my code to load the image inside

Calculate possible permutations of an array of numbers

筅森魡賤 提交于 2019-12-21 17:39:27
问题 I have an NSArray with the numbers {0,1,2,3} Calculating the factorial of 4 (the count of the array), I have 24 possible permutations of 0,1,2,3 I would like to know if there is a way to calculate all of these possible permutations and place them in a separate array. For example, given the numbers above, {0,1,2,3}, the resulting permutations would be: 0123, 0132, 0213, 0231, 0312, 0321, 1023, 1032, 1203, 1230, 1302, 1320, 2013, 2031, 2103, 2130, 2301, 2310, 3012, 3021, 3102, 3120, 3201, 3210

Swift - Insert object/item / Add object/item in NSArray

Deadly 提交于 2019-12-21 12:27:09
问题 I have this code: var NToDel:NSArray = [] var addInNToDelArray = "Test1 \ Test2" How to add addInNToDelArray in NToDel:NSArray ? 回答1: You can't - NSArray is an immutable array, and as such once instantiated it cannot be changed. You should turn it into a NSMutableArray , and in that case it's as simple as: NToDel.addObject(addInNToDelArray) Alternatively, you can insert the value at instantiation time: var NToDel:NSMutableArray = [addInNToDelArray] but that's not about adding, it's about

Annotation error in Swift for loop with array and UIView

别说谁变了你拦得住时间么 提交于 2019-12-21 12:07:12
问题 I thought it would be a great learning experiment to take a small Obj-C library and convert it to Swift. Since I eventually want to use this library in an app, I found the Path app menu example here: https://github.com/yourabi/PathMenuExample I think I've done an okay job of converting and searching for answers as I'm just starting out with Obj-C and Swift. But now I'm stuck with an error I can't find a solution for. ExpandableNavigation.swift import Foundation import UIKit; class

Strange behavoir when decoding an NSArray via NSSecureCoding

元气小坏坏 提交于 2019-12-21 12:05:20
问题 i spent all afternoon banging my head against the wall trying to figure out why decoding of this class was failing. the class has a property that is an NSArray of Foo objects. Foo conforms to NSSecureCoding, and i have successfully encoded and decoded that class by itself. i was getting an error in initWithCoder: that said failed to decode class Foo. through some experimentation, i discovered that i needed to add [Foo class] to initWithCoder: in order for it to work. maybe this will help

How to get values from NSDictionaries inside an NSArray

▼魔方 西西 提交于 2019-12-21 07:28:09
问题 I'd like to know if it's possible to get a values from a desired key inside an NSDictionary that is in NSArray . Example: NSArray *array = @[ @{@"title" : @"title 1", @"description" : @"description 1"}, @{@"title" : @"title 2", @"description" : @"description 2"}, @{@"title" : @"title 3", @"description" : @"description 3"} ]; I'd like to get (without creating a new NSMutableArray ) all the titles inside my NSArray . Maybe I'm doing something wrong and my approach is bad altogether. I know I

Storing and Retrieving from a Plist [duplicate]

有些话、适合烂在心里 提交于 2019-12-21 05:18:09
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: iOS: store two NSMutableArray in a .plist file I've always refrained from using plists as I'm not really sure how to use one. Could anyone give a simple code example of using a plist? I'm interested in saving an NSArray or NSDictionary to a plist and then retrieving it again later. Are there any advantages/disadvantages to storing either an NSArray or an NSDictionary ? Also, are there any rules with regards to

Grab all values in NSDictionary inside an NSArray

会有一股神秘感。 提交于 2019-12-21 05:10:32
问题 I have an NSArray full of NSDictionary objects, and each NSDictionary has a unique ID inside. I want to do lookups of particular dictionaries based on the ID, and get all the information for that dictionary in my own dictionary. myArray contains: [index 0] myDictionary object name = apple, weight = 1 pound, number = 294, [index 1] myDictionary object name = pear, weight = .5 pound, number = 149, [index 3] myDictionary object (etc...) I want to get the name and weight for the second dictionary

Populate tableview from NSDictionary

一个人想着一个人 提交于 2019-12-21 02:56:42
问题 I have an NSDictionary received from a json request that looks like this: RESULT : ( { Id1 = 138; lat = "45.5292910"; long = "-73.6241500"; order = "2343YY3" }, { Id1 = 137; lat = "45.5292910"; long = "-73.6241500"; order = "2343YY3" }, etc. I want to display it in a TableView (CellforRowAtIndexPath), so I obtain the data as NSArray. The method seems inefficient as each key Id1 , lat , long , etc is created as an NSArray so that I can display them each with: [self.data1 objectAtIndex