Questions tagged [nsobject]

NSObject is the root class of most Objective-C class hierarchies; it has no superclass. From NSObject, other classes inherit a basic interface to the runtime system for the Objective-C language, and its instances obtain their ability to behave as objects.

Although it is not strictly an abstract class, NSObject is virtually one. By itself, an NSObject instance cannot do anything useful beyond being a simple object. To add any attributes and logic specific to the program, you must create one or more classes inheriting from NSObject or from any other class derived from NSObject. NSObject adopts the NSObject protocol. The NSObject protocol allows for multiple root objects. For example, NSProxy, the other root class, does not inherit from NSObject but adopts the NSObject protocol so that it shares a common interface with other Objective-C () objects.

NSObject is the name not only of a class but of a protocol. Both are essential to the definition of an object in Cocoa (). The NSObject protocol specifies the basic programmatic interface required of all root classes in Cocoa. Thus not only the NSObject class adopts the identically named protocol, but the other Cocoa root class, NSProxy, adopts it as well. The NSObject class further specifies the basic programmatic interface for any Cocoa object that is not a proxy object.

The design of Objective-C uses a protocol such as NSObject in the overall definition of Cocoa objects (rather than making the methods of the protocol part of the class interface) to make multiple root classes possible. Each root class shares a common interface, as defined by the protocols they adopt.

More Information : NSObject Class reference

899 questions
0
votes
1 answer

trying to use coredata with an object class ** unsuccessfully**

I am completely lost trying to set up core data to be used inside my nsobject class. I am adding coredata to my existing project so its quite hard to figure this all out. Because of this I have started a new project with coredata to get the sample…
C.Johns
  • 10,185
  • 20
  • 102
  • 156
0
votes
4 answers

Custom NSObject class, instantiate like [CustomObj customObjWithData:data]

Possible Duplicate: Class methods which create new instances I am wondering how to emulate the instantiation of classes like NSString, NSArray and such like this: [NSArray arrayWithObject:object]... in hope of eliminating inits and allocs. I may…
glesage
  • 955
  • 2
  • 16
  • 31
0
votes
1 answer

Trouble adding a custom object to NSMutableArray inside a block

I'm sending some custom objects to a server from the app with ASIFormDataRequest inside a dispatch_async block. And when I receive OK from the server I need to put the object in a NSMutableArray. But when I try to access the the array from outside…
lagos
  • 1,968
  • 3
  • 17
  • 26
0
votes
2 answers

iOS: NSObject call and detecting which UIVIewController made the call

Hopefully this is an easy one... I have an NSObject with methods that is used in multiple UIViewControllers (the NSObject is imported in my .pch file). The UIViewControllers then make calls to the NSObject like so; [ThisNSObject doSomething]; This…
roycable
  • 301
  • 1
  • 9
0
votes
3 answers

How do you make a NSObject "global" / available in all methods?

I'm somewhat of a newbie to objective-c programming, and can't understand how to create a NSObject in one method and use it in another. For example: I have a UserObject with properties like firstName, lastName. @interface UserObject :…
Brian Weinreich
  • 7,692
  • 8
  • 35
  • 59
0
votes
2 answers

Variables losing their values before I can save them to plist

I am writing a controller class for my plist, which gets called from another class. the controller class has a read and save method, the read method opens up the plist and saves it to the documents file for reading and writing too. In this read…
C.Johns
  • 10,185
  • 20
  • 102
  • 156
0
votes
1 answer

Creating a JSONObject in iOS5

This answer seems to show how to make a JSONObject. NSString *jsonString = @"[{\"id\": \"1\", \"name\":\"Aaa\"}, {\"id\": \"2\", \"name\":\"Bbb\"}]"; NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; NSError *e =…
neuromancer
  • 53,769
  • 78
  • 166
  • 223
-1
votes
3 answers

How to change property of NSObject element in Swift array and then append it to same array

I've a NSObject class as follows: class Number: NSObject { var number: Int = 0 init(newNumber: Int) { self.number = newNumber } } And then I'm creating an array of this Number object as follows: var numbersArr =…
Animesh Porwal
  • 557
  • 1
  • 10
  • 21
-1
votes
1 answer

NSObject not retaining

Process - NSObject Class used to generate a card with certain properties. This is added to a MutableArray and used accordingly. However, after the function to determine the hand outcome in another class, the MutableArray loses all it's values. Now I…
Daniel
  • 31
  • 4
-1
votes
2 answers

Objective C: Access Variable From View Controller To NSObject

I am started learning objective c again, and I am trying to access a variable from my main view controller in my NSObject class. How would I do that? For example I have declared UITextField *name; and I want to use it in my NSObject.
chano
  • 21
  • 1
  • 8
-1
votes
1 answer

NSObject - saving in loop vs outside loop

Is there any loss in data if I save outside the loop when adding objects vs when I do it inside the loop? Asking since saving outside is much faster. Outside Loop: for(NSMutableDictionary *result in data){ [manager newManagedCaf]; …
King
  • 59
  • 8
-1
votes
1 answer

How to interrupt a Viewcontroller when another class is finished processing required data

I have two classes, one view controller an another NSObject class that performs async processes, once its done I want to interrupt the view controller similar to what a button does as IBAction, to update UI. I wanted to keep this functionality in…
Abhishek Ravi
  • 137
  • 11
-1
votes
3 answers

How to assign one class to be another?

I'm trying to create a class called Theme in my app. Ideally, what I'd like to be able to do is calling the background color for the current theme by calling: [[Theme current] background]. Now, I wrote a class called Theme. Theme.h @interface Theme…
user4992124
  • 1,574
  • 1
  • 17
  • 35
-1
votes
2 answers

How to make a TableView out of different NSObjects?

maybe somebody can help me. I Have different class objects. They'll get created in the TableView.m file with arrays as properties of these objects. How can I populate the TableView out of these Objects so that every cell contains on object? When I…
podoi17
  • 39
  • 9
-1
votes
1 answer

store NSobject data into Nsuserdefaults

In My Modal Object two values are there I'm trying to store in NSUserDefaults. This is My Code interface File: @interface collectionModel : NSObject { } @property(nonatomic,retain) NSString *name; @property(nonatomic,retain) NSString…