nsarray

How to choose an array (column) from a given file.txt? (stringByAppendingPathComponent) Xcode

会有一股神秘感。 提交于 2019-12-25 01:47:09
问题 I am trying to pick an array (column) from a given file that contains arrays of numbers e.g: 2012-09-02 16:27:15.010 SMA -0.818863 0.286575 0.206177 -0.108286 -0.231033 -0.303317 2012-09-02 16:27:15.017 SMA -1.024597 0.380875 0.456131 -0.282619 -0.123060 -0.048027 2012-09-02 16:27:15.023 SMA -0.754196 0.417053 1.165237 -0.010996 -0.078193 0.594972 2012-09-02 16:27:15.030 SMA -0.674835 0.486038 1.487640 0.061529 -0.008288 0.825637 here is my code, but it's giving nothing: NSString* filePath =

How can I Retrieve a property value from child array object?

故事扮演 提交于 2019-12-25 00:00:46
问题 I'm trying to call an object property from a child array. In the viewcontroller the categories and subcategories are loaded with name, path and images. A new class created for sub-categories able to get name and path but can't retreive the image. The Parent categories are returning all the info including icons however the sub-categories not able to get the image. ViewController.swift segue prepare. override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if (segue.identifier! ==

Find NSDate in sorted NSArray

风格不统一 提交于 2019-12-24 20:37:56
问题 I have a sorted array of NSDate objects. What I'd like to do is create a method that takes in a date and returns YES or NO depending on whether that date can be found in the date array. NSArray *dateArray; -(BOOL)arrayContainsDate(NSDate *)d { // return YES if d is found in dateArray } I know how to do this by going through each element of the array one by one, but I need a quicker way. 回答1: When determining whether an object exists in a set of objects, consider using an NSSet/NSMutableSet

Beginner: Why do I get a EXC BAD ACCESS? [closed]

雨燕双飞 提交于 2019-12-24 17:28:31
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I am geting an exception while hitting the line "self.myData = ..." GDB Program received signal: EXC_BAD_ACCESS Here's my code: - (void)viewDidLoad {

NSArray* excludedActivities Leaks memory even when using ARC and setting it to nil

坚强是说给别人听的谎言 提交于 2019-12-24 15:27:09
问题 I'm trying to use the new iOS6 UIActivityViewController and it works fine except that the Memory Leaks instrument says that the NSArray *execludedActivities is leaking every time I try to show the controller. Note that I tried to use an NSArray called excludedActivities and then set the shareShareController.excludedActivityTypes to be able to set the array to nil later (all that is commented code below) but now I'm setting the property directly and still there is a leak. - (IBAction)share:(id

Search nsarray of nsdictionary

牧云@^-^@ 提交于 2019-12-24 13:45:00
问题 I have an NSArray filled with NSDictionaries . One of the keys the dicts have in common is "name". I have another array, filled with names. I want to search the first array, if it finds a name it is supposed to add the dictionary to a third mutable array. The third array then contains all dictionary which names are in the name-array. 回答1: Use "fast enumeration", commonly also known as for-in loop: for (NSDictionary* dict in myArray) { Also, to compare NSString's, use -isEqualToString:. if ([

If a key is duplicated in an array,I want to add the values of that key

我是研究僧i 提交于 2019-12-24 12:15:25
问题 If a key is duplicated in an array, I want to combine the values of that key. For example, I have the following array. var arrays = [ ["Product":"Item0", "Price":"15"], ["Product":"Item1", "Price":"53"], ["Product":"Item2", "Price":"12"], ["Product":"Item1", "Price":"83"], ["Product":"Item0", "Price":"10"], ["Product":"Item3", "Price":"88"], ["Product":"Item0", "Price":"44"] ] And I want to change this array like this. [ ["Product": "item0", "Price": "69"], ["Product": "item1", "Price": "136"

How to use Custom ordering on NSArray

邮差的信 提交于 2019-12-24 10:48:07
问题 How can I perfrom a custom sorting operation on an NSArray. I have one array of strings which is my ordering that I want. NSArray A = {cat, dog, mouse, pig, donkey} And I have one array of strings which is not ordered the way I want. NSArray B = {dog,cat,mouse,donkey,pig} Whats the best way to put array B in the same order as array A without having to use keys? 回答1: Here's a way NSArray *sortedArray = [B sortedArrayUsingComparator: ^(id obj1, id obj2){ NSUInteger index1 = [A indexOfObject:

Sorting is not working correctly

£可爱£侵袭症+ 提交于 2019-12-24 10:17:59
问题 I am saving some files in document directory through my app using custom naming as "file1.format" ,"file2.format" and so on.Later I fetch these files in an Array and printing them in a loop then they are coming in sorted form but the problem arises when I store "file10.format" and so on. After this the result comes is some what unexpected. As after saving 10th file the output comes like file1.foramt file10.format file2.format . . file6.format file61.format file7.format I don't know why

Getting data from array of dictionaries in an array

拈花ヽ惹草 提交于 2019-12-24 08:08:02
问题 I have created an Array of Dictionaries : let tempArray = [["id":"1","Name":"ABC"],["id":"2","Name":"qwe"],["id":"3","Name":"rty"],["id":"4","Name":"uio"]] Now I have to create an array of Name only. What I have done is this: var nameArray = [String]() for dataDict in tempArray { nameArray.append(dataDict["Name"]!) } But is there any other efficient way of doing this. 回答1: You can use flatMap (not map ) for this, because flatMap can filter out nil values (case when dict doesn't have value for