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

Convert Custom NSObject to NSData

I'm trying to transfer data between 2 devices using bluetooth. I want to convert custom NSObject to NSData. What is the best way to decode the received NSData into a custom NSObject ? Thanks!
Bhavesh Nayi
  • 3,626
  • 1
  • 27
  • 42
-1
votes
3 answers

How to pass NSObject class particular data from one class to another class in ios

In my ios app I have created one NSModel Object for displaying tableList and when I tapped on tableList row I want to take that particular model class object data to another class How can I do this? my code: NSMutableArray * mainArray; //TableList…
Krish
  • 4,166
  • 11
  • 58
  • 110
-1
votes
1 answer

Passing Data from view Controller to NSObject class

I know how to pass the data from one view controller to another view controller ,now i want to know how to pass a textfield value from view controller to NSObject class and how to store the recieved in nstring .Please help me to do this , Can…
-1
votes
5 answers

How to access variable from NSObject class?

I'm trying to learn mvc design pattern in swift. So I made the model class named User like below : class User: NSObject { var email : String! var password : String! var profilePictureUrl : String! init(email: String, password: String,…
Ega Setya Putra
  • 1,645
  • 6
  • 23
  • 51
-1
votes
4 answers

Ambiguity regarding the usage of NSObject?

I am new to ios development and started coding with swift,and I have some basic question regarding NSOject and i couldn't find any satisfactory answer. My question is, If we are creating a new class ,is it mandatory that the class must inherit from…
Legolas
  • 805
  • 1
  • 11
  • 24
-1
votes
1 answer

Call method after asynchronous request obj-c

In my app I init a new object, where there is method which calls NSURLConnection's sendAsynchronousRequest method. After the request, I would like to call a method in the caller UIViewController. I tried to use a static method but I then I can't…
-1
votes
3 answers

How do I create a private global variable in an NSObject class?

I want to create a private global variable in an NSObject class. Here is what I have so far: + (MyClass *)sharedInstance { static MyClass *sharedInstance; static dispatch_once_t once; dispatch_once(&once, ^{ sharedInstance =…
Hudson
  • 21
  • 3
-1
votes
1 answer

Custom NSObject Class: No longer able to add objects

This was working and then it stopped.I've undone changes and it's still not working. And, I've got a very similar custom NSObject class that works fine. Here's the deal... I have this custom class that will eventually be populated with data from a…
SteveSTL
  • 998
  • 3
  • 13
  • 21
-1
votes
1 answer

How come the instance of my object is missing the properties I want to assign?

I am trying to create a class in with properties defined in the header. Was planning to populate the object in a for loop. Here is the header, what could I be doing wrong? Am I defining this class wrong? #import #import…
Jack Shultz
  • 2,031
  • 2
  • 30
  • 53
-1
votes
2 answers

When subclassing NSObject, what difference does it make to import "Foundation.h" or "NSObject.h"?

Here we see the same subclass of NSObject each using a different #import statement. What difference, if any, does this make for my subclass? What difference, if any, does this make for my final compiled program? #import
Aya Aboud
  • 371
  • 2
  • 4
  • 16
-1
votes
2 answers

Pass NSObject (conditional data) to TableView

Firstly, sorry if the title is confusing, I'm not sure how else to word it. I'll explain my app briefly. User is presented with a Login screen (very basic, no server-side stuff), in which they can log in to three different companies (Company A,…
rosshump
  • 370
  • 1
  • 4
  • 21
-1
votes
2 answers

initwithtarget:self where self is NSObject

Let's say that I want to create a GestureRecognizer object and have my whole logic in there. So when I add the NSObject as target for my recogniser: initWithTarget:self action:@selector(doTheRecognizerThing:) I'm facing an issue and I'm not sure…
alecnash
  • 1,750
  • 1
  • 18
  • 42
-1
votes
1 answer

Creating dictionary with custom class object

I have Custom class. I want to add to this class property with type NSDictionary that will return properties of this class by given tag. But I can not do it. Is it possible or not? I have error: [__NSPlaceholderDictionary…
-1
votes
1 answer

Pausing the execution of main thread until NSWindow closed

I am newbie in objective-c.I want to pause the execution of main thread until my application keyWindow has been closed.I have tried by following code [mywindow performSelector:@selector(isVisible:) onThread:[NSThread currentThread] withObject:self…
-1
votes
2 answers

How is comparing operator '==' for NSObject

How is comparing operator '==' for NSObject? Method -isEqual: works fine for me, but when I'm using -isEqual I need to check if objects exists. With '==' I don't need to check this but where I can find documentation for it?
Igor Bidiniuc
  • 1,540
  • 1
  • 16
  • 27