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
-2
votes
2 answers

How to create a shared class and use it in another classes in swift

I need to use a shared class for my new project for reusing objects and functions in swift .I also need to know how this can be used in another classes. Thanks in Advance Berry
-2
votes
1 answer

Passing value from ViewController to NSObject in Objective-C

I need to pass value from a ViewController to NSObject as soon as the view loaded using Xcode with Objective c. I am using the code below but the value is null. -(void)viewDidAppear:(BOOL)animated { MyHomeModelNSObject *nsOb; nsOb =…
user3741700
  • 21
  • 1
  • 6
-2
votes
1 answer

UITableView using xib file, NSObject subclass and using in UIViewController

I created a single view project in Xcode which by default includes ViewController file. I created a NSObject subclass named MyClass. I #import in MyClass. MyClass confirms to UITableViewDelegate and UITableViewDatasource Implemented…
S.J
  • 3,063
  • 3
  • 33
  • 66
-2
votes
1 answer

Extract value from NSObject key/value pair

I have a NSObject variable which represents something like : {objectID : 2, name : John Doe, url : www.test.com } I want to extract only the url from the NSObject variable. How can I do that?
user782400
  • 1,617
  • 7
  • 30
  • 51
-2
votes
5 answers

-[Person componentsSeparatedByString:]: unrecognized selector sent to instance

I'm new to programming, and I feel a little intimidated posting, and I'm stuck. I don't want a quick fix! Please help me understand this. I've created a custom method with a name, age, height and gender. It gets called when the NSMutableArray adds…
Jay
  • 49
  • 6
-2
votes
2 answers

Change or Update NSMuttableDictionary

How to Change or Update NSMuttableDictionary i apply code below in User.h file the code @interface User : NSObject @property (nonatomic, strong) NSNumber *userID; @property (nonatomic, strong) NSString *avatar; @property (nonatomic, strong)…
kagmanoj
  • 5,038
  • 5
  • 19
  • 21
-2
votes
2 answers

How to convert NSString to NSObject?

In my project i need to compare and NSString with NSObject. How to convert NSString to NSObject. OR Is there any chance to compare NSString with NSObject.
user2230971
  • 287
  • 1
  • 7
  • 22
-2
votes
4 answers

How to process an object into an NSMutableArray

I have an object like this: @interface object : NSObject { NSString *_observation; NSInteger _id; NSString *_date; NSString *_device; double _latitude; double _longitude; } So as you see it has some…
-3
votes
1 answer

How do i save a custom NSObject class to file?

I tried: NSData *data = [NSKeyedArchiver archivedDataWithRootObject:dictionary]; BOOL success = [data writeToFile:entryPath atomically:YES]; But for whatever reason, it crashed with this error: 2012-03-24 20:06:13.550 Journal[1348:707]…
Andrew
  • 15,935
  • 28
  • 121
  • 203
-3
votes
1 answer

Set property of NSObject

Somehow i can not change the properties of my custom object anymore. I used Xcode 6 to create my project and moved to XCode 7 now. It told me to "update to recommended settings" and i did it. Object.h @interface Object : NSObject…
-3
votes
1 answer

Get first letter index from NSObject property in NSMutableArray

I store NSObject (person) in NSMutableArray (self.tableData). I would like to use section like in Address contact : sort alphabetically every fullName in my NSMutableArray (already done), and access it with index on the right "A,B,C,D..." I have to…
Vjardel
  • 1,065
  • 1
  • 13
  • 28
-3
votes
2 answers

Basic difference between following NSString assignment calls

// Directly assigning the value. NSString *str = [objDictionary objectForKey:@"attributeName"]; // Assigning with convenience method NSString *str = [NSString stringWithFormat:@"%@", [objDictionary objectForKey:@"attributeName"]]; // Assigning…
viral
  • 4,168
  • 5
  • 43
  • 68
-4
votes
1 answer

NSLOG does not work

I try to get info for the array in the console but the NSLOg does not show anything. This is a class where i store data for the app. Here is the code. #import #import "DAObject.h" @interface DataModel :…
Newbie
  • 25
  • 7
-4
votes
1 answer

Compare NSObjects ignoring pointers

I have a model class (subclass of NSObject) which I am storing in 2 mutable arrays. In one array I am storing the objects directly and in the other I am storing a copy of it using [myObject copy]. I would like to compare these 2 arrays by ignoring…
user2990765
  • 387
  • 2
  • 3
  • 16
1 2 3
59
60