Questions tagged [nsdictionary]
A member of Apple's Objective-C framework Cocoa. NSDictionary objects manage associations of keys and values.
4,107
questions
0
votes
1
answer
22
views
Defining the type of a completionHandler in Objective-C
I can't manage to get the responseCompletion type correct, at the for cycle.
Tried to replace it with typedef, but got no luck, only more errors.
@interface ImageManager : NSObject
//typedef void(^...
1
vote
1
answer
283
views
FIRInvalidArgumentException, reason: Document path cannot be empty
I am trying to access some values in a dictionary I made from Firebase snapshot, I use these values to access some document in my firestore, but these values come back empty therefore the path I used ...
1
vote
1
answer
53
views
Complex Dictionary Get Values as Strings With Conditions
I have built a survey using laanlabs/SwiftSurvey and I am able to get the results from the surveyComplete method as a dictionary.
The results return in a complex structure and I need to get the values ...
1
vote
0
answers
253
views
Not sure how to use unarchivedDictionary to resolve a NSInvalidArgumentException crash using userDefaults within Swift
I'm hitting the issue documented here and I'm trying to utilize NSKeyedUnarchiver.unarchivedDictionary, but I'm not sure what KeysofClasses or objectsOfClasses is wanting.
The structure of my ...
1
vote
1
answer
100
views
How can I store an NSDictionary in a String:String?
I'm trying to load a plist (keys are unique words, values are their English-language definitions) into a dictionary.
I can do a one-off like this:
let definitionsFile = URL(fileURLWithPath: Bundle....
1
vote
0
answers
95
views
Convert array inside of a Swift Struct to NSdictionary
Below is my code which the DataModel struct is converted to a NSDictionary
struct DataModel: Decodable {
let id: String
let carID: String
let ownerId: String
let services : [Service]
...
0
votes
0
answers
177
views
NSInvalidArgumentException Unacceptable type of value for attribute: property; desired type = NSString; given type = NSNull; value = <null>
Problem: when assigning the null value to a property it gives error: desired type = NSString; given type =null.
Recieving this value from NSDictionary *logBookClass = [json objectForKey:LOG_BOOK]; ...
0
votes
0
answers
39
views
Set variable (reference) from dictionary to new value
How can i change the value of a variable that is referenced in a dictionary.
func setApiItem(name: String, setTo: String) {
var refs = [
"apiKey" : self.apiKey,
"...
0
votes
1
answer
201
views
How to access indices of an NSDictionary, and convert that key’s value to an Int in Swift?
I’m trying to access indices of an NSDictionary, and convert that key’s value to an Int using Swift.
I’m also using an API to fetch data. The API response is what I’m using to create an initial ...
0
votes
0
answers
141
views
Thread 1: signal SIGINT when getting a value from NSDictionary
I'm trying to get values from NSDictionary using the inbuilt get() func, but each time i use the get func the app crash, and xcode doesn’t print any message except "Thread 1: signal SIGINT".
...
0
votes
1
answer
262
views
How can I specify the key and value datatype of an NSDictionary argument in swift?
I would like to define a function in swift that can be used in objective-c as well. I have a enum:
@objc public enum BookType: Int {
case novel
case magazine
func name() -&...
0
votes
2
answers
450
views
How to make an object from a Dynamic dictionary swift
This is my json:
"latest_receipt_info" = (
{
"expires_date" = "2022-02-15 07:33:27 Etc/GMT";
"is_in_intro_offer_period" = false;
...
0
votes
0
answers
40
views
Iteract through __NSSingleObjectArrayI in Objective-C
I'm getting the below response and how do I iterate or get the values?
<__NSSingleObjectArrayI 0x600002edeea0>(
{
link = "<null>";
ValueG = "%";
ValueT = 1;
...
-1
votes
1
answer
292
views
iOS CFMutableDictionaryRef crashes on iOS 15 and newer but still work on iOS14
I wrote two functions in Objective-C to generate a key pair with method SecKeyCreateRandomKey. In one I use the NSDictionary in another CFMutableDictionaryRef.
The function where I use NSDictionary ...
1
vote
0
answers
22
views
Use Mirror(reflecting: ) on Core Data NSManagedObject [duplicate]
I use the following code to add an object to Core Data. Why is it when I use Mirror(reflecting: ) on the the object, nothing prints out?
Saving works fine.
var dict = [String: Any]()
dict.updateValue(&...
-1
votes
1
answer
625
views
are dictionary keys that conform to Hashable protocol having update to its reference object
Say I had a class called Example, it conforms to Hashable via its ID attribute.
I have an Example object exam1, with ID = 6 and name = "goon". I set a dictionary entry dict[exam1] = 7.
Then ...
0
votes
1
answer
164
views
Unable to find key for specefic value in swift Dictionary
i tried to get tempFileName from URLSession error and decode resumeData to a dictionary with below code
let resumeDictionary = try! PropertyListSerialization.propertyList(from: data, options: [], ...
0
votes
3
answers
287
views
Rust Cocoa - How to make an NSDictionary?
I've been reading around trying to understand it. You can see here dictionaryWithObjects:objects the takes an array of Objects and Keys:
NSDictionary *dictionary = [NSDictionary dictionaryWithObjects:...
0
votes
1
answer
80
views
NSDictionary count of objects (0) differs from count of keys (1) Crashing app after new Xcode
I have an app which will take a plain text file, and for each question, create an entry in a PLIST file with different choices for answers, etc. I have used this same code for a few years, but for ...
-1
votes
1
answer
1k
views
Swift JSONSerialization.data crashing
I have a example 2 struct below,
struct Person: Codable {
let a: String
let b: [Department]
}
struct Department: Codable {
let bb: String
}
let dict = ["a": "aa", &...
0
votes
0
answers
34
views
NSMutableDictionary content objects comply to NSCopying protocol
I am on objective-c, macOS.
I have an options Dictionary declared like this
@property NSMutableDictionary* options
Now the object containing the dictionary needs to be copied with copyWithZone ...
1
vote
1
answer
315
views
Swift - Core Data - using the result of fetch with GroupBy
I couldn't find answer to this question, I checked all questions here.
Summary:
I don't know how to use the result(that I successfully get back) of .fetch() method with GroupBy. The fetch method ...
0
votes
1
answer
600
views
Parsing Data Out of Dictionary<String, Any> in Swift
I'm trying to extract data out of a Dictionary<String, Any> in Swift. The dictionary returns the following when I run NSLog("\(terminalDict)"):
Optional(["DFEE22": <...
0
votes
2
answers
648
views
convert string to dictionary in swift 5?
I have a string which contains a json in the following format:
var myString: String = "{key1: val1, key2: val2}"
How can I convert this to:
var myJson: [String: String] = ["key1": &...
0
votes
2
answers
225
views
BOOL value changing from NO to Yes when setting up from NSDictionary
I have this code
if ([args valueForKey:@"showSetupScreen"]) {
BOOL showSetupScreen = [args valueForKey:@"showSetupScreen"];
NSLog(showSetupScreen ? @"YES" : @&...
0
votes
1
answer
336
views
Why am not able to access my model class in Swift Project?
How to access my Model from ViewController and use the Model data to load in table view????
Source Code Link
My ViewController looks like this
import UIKit
class ViewController: UIViewController {
...
0
votes
1
answer
146
views
SwiftUI Store and Extract Dictionaries from UserDefaults.standard
So for Userdefaults.standard, I stored dictionaries for some keys, but I don't know how to access the values from it.
For those keys, value is supposed to be a dictionary, but I'm assuming the ...
-2
votes
1
answer
200
views
Get all key values from NSDictionary in order Objective C
I need to get all keys of a Dictionary with its values.
for example
I have a dictionary like:
{
"Last_Settled_Amount" = "7056.92";
"Last_Settled_Date" = "...
0
votes
2
answers
136
views
Attempt to insert non-property value problem in Objective C [duplicate]
I've been stuck with this problem for like few good hours and to be honest can't find the solution, I'm trying to store NSDictionary using UserDefaults, but for some reason it crashes in runtime at ...
0
votes
0
answers
51
views
What is the difference between CFDictionaryContainsKey and CFDictionaryGetCountOfKey
CFDictionaryContainsKey
CFDictionaryGetCountOfKey
It seems that they both return 1 if the key is found and 0 if not. Any difference?
0
votes
1
answer
112
views
still having trouble with my FCM http request
I just want to be able to send a notification to users subscribed to a certain topic with no errors.
Here is my function I use to try to accomplish this goal:
func sendNotificationToUser(to topic: ...
0
votes
1
answer
199
views
how do I convert my data to JSON format - health app
I am very new to swift.
I need to create the below JSON format
{ "items" : [
“BloodPressure:” {
"endDate" : "2020-01-25",
“systolicValue” : "122&...
0
votes
3
answers
102
views
How can access JSON subfield using NSDictionary in swift
My First JSON is below:
{
"status": 1
}
My code is below:
let dict: NSDictionary!=(try! JSONSerialization.jsonObject(with: data as Data, options: JSONSerialization.ReadingOptions....
0
votes
2
answers
549
views
How to get Firebase data as a model in swift?
I am trying to get data from firebase and use it as a model that I created.
Here is my model;
class UserData{
var nickname : String = ""
var onesignal_player_id : String = ""
var ...
0
votes
1
answer
191
views
“Old-Style ASCII Property List” to Json in Swift
I have a string that looks like following:
{\n \"account_no\" = \"5675672343244\";\n \"account_kind\" = {\n \".tag\" = test,\n };\n ...
-3
votes
1
answer
57
views
Parse Alamofire result swift
I'm very lost parsing the following response from an AF request – let json = result as! NSDictionary – in Swift:
{
errors = (
);
get = statistics;
parameters = {
...
0
votes
1
answer
107
views
Get all keys exists in NSDictionary and put into Array
When I snapshot from child "abc" I got this NSDictionary, "3c" can be added more nested childs. How can I get all the keys within an NSDictionary and put into Array
Expected result:...
-1
votes
1
answer
282
views
How to add NSDictionary as a value in Objective-C?
I have a property:
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSMutableDictionary<NSString *, NSString *>*>*mainDict;
So it is a dictionary with another dictionary as ...
-1
votes
1
answer
34
views
How to access NSMutableDictionary when the key looks like an int?
I'm learning objective-c.
I tried to grab the entry of this NSMutableDictionary by using numbers as the key:
// [game analysisData] returns the Dictionary
NSMutableDictionary *data = [game ...
1
vote
2
answers
67
views
I can't Unwrap a value from a plist key value
I'm new to swift and I'm trying to load a property from a nsDictionary to vTitle
var nsDictionary: NSDictionary?
if let path = Bundle.main.path(forResource: "AppData", ofType: "...
0
votes
0
answers
71
views
Swift reconstructing subclasses from dictionary/plist
I am reading dictionary from a plist file and based on the object type I want to construct and initialize objects of appropriate class. Here is my code:
enum ItemType:String {
case type1, type2, ...
0
votes
0
answers
61
views
Display contents of NSDictionary in NSOutlineView and update this data
I need to display the content of a NSDictionary in a NSOutlineView.
I do this by using a struct that holds my data and which is used by my NSOutlineView as DataSource.
struct DataItem {
var ...
0
votes
2
answers
266
views
Objective-C How to add objects to NSMutableArray from other place?
Hello I'm junior in Objective-C and Swift programming.
I have NSMutableArray in ExampleMenuViewController.m or(and) SomeClass.m declared as vcTabs.
NSMutableArray *vcTabs;
When I have two declares '...
1
vote
0
answers
99
views
Can't populate empty dictionary in Swift
I am trying to build a flutter plugin for the Sendbird iOS SDK. For some reason whenever I try to fetch data, I get null from a NSDictionary<NSString *,NSObject *> when I know for a fact that ...
0
votes
2
answers
1k
views
Unable to parse a json data in swift
I have a API response as given below:
{
"status": 200,
"schedule_data": {
"2020_08_16_1597485600": {
"schedule_date": "2020-08-...
1
vote
1
answer
101
views
A question about NSDictionary initialization
the result is 4 2 3, but what happened in the process of initialization of this NSDictionary?
it's because that its assignment just execute at first time and ignore the rest assignment to same key? Or ...
0
votes
1
answer
165
views
How to save an NSDictionary with NSValue objects to a file
I have a flat NSDictionary with keys as NSNumber objects and values as NSValue objects. How do I save this to a file?
I've tried writing the dictionary directly to a file and also archiving to NSData ...
0
votes
1
answer
310
views
Decode NSDictionary with functions inside as values to swift object
any advices or suggestions will be appreciated! Thanks!
I have an issue to solve and it seems I can't find the answer anywhere. Some context: we are updating our ios app and the production version is ...
0
votes
1
answer
50
views
Unable to get the key of a value from an NSDictionary in Xcode
I was trying to get the key of a value by using the value itself from an NSDictionary in my Xcode project. I am using the following dictionary:
_itemDictionary = @{
@"Electronics" : @...
1
vote
1
answer
601
views
How to post null values in JSONSerialization parameters if some of the variables are nil in swift?
my code looks like this. I've around 10 parameters and some of the values can be nil and if the values are nil, I need to http post those nil values as null.
func someFunc(userId: Int, param1: String?,...