Questions tagged [nsarray]

An immutable, integer-indexed array of objects from the Apple Foundation framework.

nsarray
Filter by
Sorted by
Tagged with
0 votes
1 answer
159 views

Why do I get the error: "Class is not key-value coding compliant for key major" even though major is a property of the class?

I am attempting to use NSArrays and NSPredicates to filter certain cells of a UITableView. I have a TableViewController class called FilterTable that is made up of FilterCell, which is a subclassed ...
hebbajeeba's user avatar
0 votes
0 answers
239 views

How to limit array to show 5 items and on button click load 5 more

I have an array of comments, but I only want to show 5 comments. On click load more comments i want show previous 5 comments + 5 new comments. Getting comments from api if let arr : NSArray = ...
Bilal Nawaz's user avatar
0 votes
1 answer
86 views

I am getting values in for loop. It is getting crashed

I am getting values from and Array[String:Any] type array in a for loop but it is getting crashed when going on first line in for loop . Actually I have created an array (Array[String:Any]) Type and ...
Coding's user avatar
  • 85
1 vote
1 answer
137 views

Getting value of NSCoding into string - KeychainWrapper

I am using KeychainWrapper to store a dictionary value however retrieving the items in a string value has come at a problem. I've tried the following: KeychainWrapper.standard.object(forKey: "...
James B's user avatar
  • 37
-2 votes
1 answer
98 views

How to filter the Array of Dictionary if the dictionary elements are null?

I need to filter the array of dictionary , but in my structure some of the values are null "data": [ { "date": "2019-04-12 00:00:00", "points": 825, "...
Nandhakumar's user avatar
5 votes
4 answers
2k views

How to sort in swift by a BOOL without changing the original order in main array?

I have one array of models which has 2 properties: 1. title (String) 2. isSelected (Bool) I want to sort them based on the isSelected property such that it does relatively to the sequence of source ...
NSPratik's user avatar
  • 4,752
1 vote
2 answers
65 views

Change color of chess field after rotate

I newbie in Obj-C. I have the following chess field: for (int row = 0; row < 8; row++) { for (int column = 0; column < 8; column++) { CGRect square = {horizontalOffSet + (column * ...
somerk's user avatar
  • 51
3 votes
1 answer
291 views

Why is NSArray mutable when used from Swift?

I have an objective-c header with the following property @property (nullable, nonatomic, strong) NSArray<CustomObject *> *customObjects; If I create a swift extension of that class I can now ...
Makaronodentro's user avatar
0 votes
1 answer
91 views

-[NSString longLongValue] ignores my string after 0x [duplicate]

When I use this code to convert a string inside a array to a long long, it fails and prints out "0" because the string starts with "0x". This is my array: NSArray <NSString *> *offsets = @["...
user avatar
0 votes
0 answers
54 views

Convert NSArray to specific object type without loop [duplicate]

I'm trying to cast an object in an NSArray; the below loop clearly explains what I'm trying to achieve, but can I do it without a loop? NSArray* inputs = [star activeStars]; for (Galaxy* object in ...
Gregor Isack's user avatar
  • 1,111
1 vote
1 answer
164 views

ios objective-c const CGFloat *

when I am calling setLineDash:(nullable const CGFloat *) count:(NSInteger) phase:(CGFloat) method by passing @[@1.0,@2.0] as (nullable const CGFloat *) UIBezierPath *path = [self drawLine:start ...
Jin's user avatar
  • 53
0 votes
1 answer
143 views

Sort NSSet of custom objects by one attribute in Objective-C

I am trying to sort an array by the most common value of a property or attribute. This question and others suggest you can do this efficiently using an NSSet. However, it is merely sorting by most ...
user6631314's user avatar
  • 1,801
3 votes
2 answers
696 views

Swift combine different type into one array to display data for UITableView

I have tableview where I need to show few sections. You should imagine this table like a playlist of your songs. In the top first section I need to display a cell with button which will add more songs ...
Oleksandr Matrosov's user avatar
-3 votes
2 answers
2k views

Swift Array append not appending values but replacing it

I am trying to add some dictionaries into an array and save it using UserDefaults, but the problem is the array doesn't append new dictionary but only replaces the dictionary. How can I fix this issue?...
iOS.Lover's user avatar
  • 5,981
0 votes
1 answer
688 views

NSArray's mutableCopy - performance concerns

I have the following concern. I have a piece of code where I care about performance a lot (to be honest, I'm trying to make it as much optimized as possible). I have something like this: NSArray *...
user1880342's user avatar
-4 votes
2 answers
158 views

Combine large number of NSArrays into single NSArray in Objective-C or Swift

I can combine two NSArrays with the following code: NSArray *combinedArray =firstArray?[firstArray arrayByAddingObjectsFromArray:secondArray]:[[NSArray alloc] initWithArray:secondArray]; If you have ...
user1904273's user avatar
  • 4,654
0 votes
1 answer
39 views

Filter NSArray of Arrays by One Element of Array Using NSPredicate in IOS

It is possible to filter an array of strings as follows: NSArray *array = @[@"honda",@"toyota",@"ford"]; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@",@"ford"]; ...
user1904273's user avatar
  • 4,654
1 vote
1 answer
1k views

Objective-C how to convert a NSArray to Byte array?

I'm not very experienced with objective-c and I would need to advise for the following use case: I'm coding a React native module for ios and one of the native methods on the ios side receives an ...
Żabojad's user avatar
  • 3,035
0 votes
0 answers
210 views

Filter Array of ManagedObject FetchResults in Swift

In objective-C you can filter an array of fetched results from core data as follows: NSString *brand = @"honda"; NSPredicate *predicate = [NSPredicate predicateWithFormat: @"brand like %@", ...
user1904273's user avatar
  • 4,654
0 votes
2 answers
336 views

__NSSingleObjectArrayI in Coredata

I am working with Coredata. i have an relation with the entity when i fetch my relation it gives the NSSet and i Convert this to NSMutableArray with AllObjects. The issue it gives me ...
Yogesh Patel's user avatar
  • 1,987
0 votes
1 answer
47 views

create new UILabel when conditions are met looping through NSArray

I have an NSArray with various parts divided by ,. this array is much longer citiesArray10000 = [NSArray arrayWithObjects: @"33.572162&-112.087966&Phoenix&...
user1114881's user avatar
0 votes
0 answers
53 views

I'm getting an error with my code "layer = <CALayer: ADRESS>>'s window is not equal to <UIImagePickerController: ADRESS>'s view's window!"

I am trying to call the takePhoto function and use an imagePickerController() method to try and segue to a different view controller that contains an UIIMageView. I am trying to pass the photo taken ...
J . D's user avatar
  • 1
0 votes
1 answer
327 views

index 0 beyond bounds for empty NSArray with asset.tracks(withMediaType:)

I try to crop a video by taking a precise size of it, but I have an error with the asset.tracks(withMediaType: AVMediaType.video)[0] line that returns me a index 0 beyond bounds for empty. I precise ...
ΩlostA's user avatar
  • 2,541
0 votes
2 answers
164 views

Array filter with aggregate operators

array.filtered does not exist in Swift anymore, I am looking for a way to use 'IN' operator in array.filter closure same as how I used it with NSPredicate. Before the query was something like let ...
XiOS's user avatar
  • 1,735
1 vote
2 answers
182 views

Repeating Number Array

I am having trouble creating a program that takes in numbers in an Array and returns them by a string. My following code in my main.m file: #import <Foundation/Foundation.h> #import "...
OmieiOS's user avatar
  • 29
0 votes
2 answers
92 views

Access values in two dimensional NSArray in Objective-c

For the following two-dimensional array, I'd like to search the names for say John and then be able to retrieve the name John Smith and the id for John. NSArray *employees = @[@[@"John Smith",@"1"],@[...
user1904273's user avatar
  • 4,654
0 votes
1 answer
2k views

Swift - Array filter and then update the main array

let cities = [{ "name" : "SF", "id" : 4, "population" : 10, favorite: false}, { "name" : "NY", "id" : 5, "population" : 20, favorite: false}, { "name" : "DC", "id" : 6, "population" : 30, favorite: ...
Paragon's user avatar
  • 992
-2 votes
1 answer
55 views

How to fetch data of NSString from array of structure hold by NSMutableArray in objective c?

I have one NSMutableArray tempArray = \[NSMutableArray array\]; which contains an array of structured objects with multiple data: brand_package_id , slide_master_id etc.... I want to sort out the ...
Tofik Tamboli's user avatar
-1 votes
1 answer
138 views

How to create ranges from NSArray by filtering matching conditions?

NSArray *objects = @[object1, object2, object3, object1, object5, object1, object6, object7]; How would be best to get the ranges delimited by object1 like this: (0-2 3-4 5-7) I know of this method ...
Kane Buckthorpe's user avatar
0 votes
2 answers
39 views

Deleting the first item in plist saved on device

Sorry this is a bit long but I have been struggling with this for a week now... I have created a location tracking iOS application by modifying this code. The LocationManager files adds a new location ...
Amy Shin's user avatar
-1 votes
1 answer
211 views

i cant get data from NSArray(contentsOfFile: ) and it's return nil

i have a problem i want to get data from a plist file and put it to an array variable but it doesnt work let path = Bundle.main.path(forResource: "SampleData", ofType: "plist") let dataArray =...
mohsen's user avatar
  • 4,860
0 votes
1 answer
86 views

Quickly Parse Phone Numbers of Contact Object in Objective-C

I am wondering if there is a more efficient way of identifying which phone numbers in a contact are populated than going through one by one and checking. Perhaps there are dictionary or array methods ...
user6631314's user avatar
  • 1,801
0 votes
1 answer
155 views

How do I remove objects from an NSMutableArray matching an NSNumber

I have an array like this: { id = 8281; name = “John”; title = “Title One“; }, { id = 8729; name = “Bob”; title = “Title Two“; }, { id = 8499; ...
J. Moss's user avatar
  • 33
0 votes
1 answer
138 views

How to Create and Sort an Array of Dictionaries of Floats

I have a custom object that contains some properties that are floats (as well as others that are strings, dates etc.). Discarding the non-float properties, I would like to filter out non-zero ...
user1904273's user avatar
  • 4,654
0 votes
1 answer
137 views

Nesting arrays in Realm with Swift

I have read several examples on SO on how to store arrays of data to Realm. Still, I am not finding a particularly clear example. In short, I have a (simplified) JSON as below which I would like to ...
user avatar
0 votes
2 answers
101 views

Facing Problem in encoding array of dictionary to JSON

In POST request I have to send following JSON data { "users": [{"userid": 16, "meetAt":"Some place (College/trip etc)", "showFields": "11111111000"}, {"userid": 17, "meetAt":"Some place (College/...
Rizwan's user avatar
  • 3,486
0 votes
0 answers
225 views

SAMKeychain Delete All Account

I'm using this library to manage username and password by saving them in the keychain. I'm having some problems to delete service accounts. Does anyone use this library? How can I delete all the ...
kAiN's user avatar
  • 2,677
-1 votes
4 answers
199 views

IOS/Objective-C: Sort NSArray of NSStrings by number of words in string

I have an array of strings that I would like to sort by the number of words in each string. I am weak, however, on dictionaries and arrays and having trouble doing this efficiently. One way might be ...
zztop's user avatar
  • 751
1 vote
1 answer
86 views

Return NSArray function from asynchronous BLOCK

I have a function that must have this signature and must return an array of Test objects + (NSArray <Test *>*_Nullable) getAllDetails Within the function I am doing a GET request using RESTKIT ...
Alex McPherson's user avatar
2 votes
1 answer
3k views

Get Firebase Documents as Array

I've created a document which contains an array within Firestore. I now want to store that array locally within my app I have create an array manually, But how can I populate it with the data from ...
Oliver Ferris's user avatar
-2 votes
2 answers
53 views

Fast enumeration Arrays of Dictionaries

I have an array of dictionaries in following format. myarary = {day = 0; hour = 1; value = 0;},{day = 0; hour = 2; value = 0;}.... {day 6 =1; hour =23; value =1;} So basically 7 days, 24 hours ...
humble_pie's user avatar
0 votes
0 answers
123 views

Convert SwiftyJsonArray to NSArray

I am using SwiftyJson for JSON parsing. I want to store the received array in LocalStorage using NSUserDefaults. But it is throwing error - "terminating with uncaught exception of type NSException" ...
A Kumar's user avatar
  • 11
0 votes
1 answer
72 views

NSArray ArrayController SelectedObjects nil

I have a coredata app with an Entity called Product. In my interface I have an array controller for this entity called ProductAC. I have bound a table view and text fields to the array controller and ...
Amy's user avatar
  • 3
-2 votes
2 answers
1k views

How to filter an array of generic type in iOS

I have a function to which I am sending an array of objects. What I want to do is to filter this array of objects using their values, since the objects may not have common properties like name, age, ...
iCodes's user avatar
  • 1,417
0 votes
2 answers
66 views

Looping through the value in Textfield for Particular Text

I have a TextField which has values as shown below. @"Testing<Car>Testing<Car2>Working<Car3 /Car 4> on the code" Here I have to loop through the text field and check for the text ...
Namratha's user avatar
1 vote
2 answers
845 views

Convert a vector<dlib::point> to an NSArray so it can be passed to a Swift class

I'm using dlib's facial landmark detector and want to store the facial landmark coordinates in an array that can be used in Swift. At the minute I've stored the landmark coordinates in a vector: std:...
Hardy143's user avatar
  • 587
1 vote
0 answers
104 views

NSCoding issue with iOS 12

While using iOS 12, I encountered an issue: I have a custom class named ClassA conforms NSCoding protocol, ClassA has a NSArray property, this array contains only one kind of custom ClassB's objcts, ...
fizix100's user avatar
0 votes
1 answer
221 views

Objective C - Accessing typedef block pointer to add and remove from NSArray

I have a typedef typedef void(^MyCompletionBlock)(NSDictionary *info); - (void)populateWithCompletion:(MyCompletionBlock)completion { NSMutableArray *array = [NSMutableArray new]; [array ...
davis's user avatar
  • 1,921
0 votes
0 answers
164 views

Update the values of particular key in json returned array of dictionary in SWIFT

I am getting some response in JSON data array of dictionary format. I need to update the value for particular keys which are 'TotalValue' and 'IndexValue' (making their values rounded of to 2 decimal ...
user avatar
0 votes
1 answer
143 views

Merge multiple csv files with difference header tile in Objective C

I have multiple csv file with difference header tile, and I want to merge all of them & keep combination Header title. I think I can doing cover csv to array then compare header tile in all file ...
Jacky Le's user avatar