Do static objective-c classes have to subclass NSObject?

In my objective-c project, I have a weird, lets say, feature I have a class, like this:

#import <Foundation/Foundation.h> @interface Convert /* : NSObject */ // <--- is that necessary? +(int) toInt:(id) obj; @end @implementation Convert +(int) toInt:(id) obj { return [obj intValue]; } @end

What happens is, when I step through the code It works fine, but I get a cryptic error in the console (even though code is completely fine, works as expected):

2010-11-03 09:35:49.422 Tests[14066:5f03] *** NSInvocation: warning: object 0x9e424 of class 'Convert' does not implement methodSignatureForSelector: -- trouble ahead 2010-11-03 09:35:49.422 Tests[14066:5f03] *** NSInvocation: warning: object 0x9e424 of class 'Convert' does not implement doesNotRecognizeSelector: -- abort

Yet, even when It says abort, the code still works. However, when I run it without stepping through those lines of code, it aborts. What Is happening and why?

-------------Problems Reply------------

The simple answer is "yes".

Or more specifically, the runtime expects objects to conform to the NSObject protocol, and the simplest way to do this is by making sure your objects inherit from the NSObject class.

Category:objective c Views:0 Time:2010-11-03

Related post

  • Initializing static objects - Code design question 2008-10-09

    In my webapplication (C#, .Net 3.5), made up of a core class library (containing the business logic, data layer and a couple of utility classes), a windows service project, a webservice project and the website project, I have a couple of static class

  • How can I animate a static object in a WPF storyboard 2008-12-18

    I have a WPF program to which I need to add a "Demo mode". Since I want my designers to be able to modify the demo mode without me having to recompile the program each time, I tough it would be a great idea to use a storyboard from an external XAML f

  • Destruction order of static objects in C++ 2009-01-22

    Can I control the order static objects are being destructed? Is there any way to enforce my desired order? For example to specify in some way that I would like a certain object to be destroyed last, or at least after another static object? ----------

  • Using static objects in XAML that were created in code in Silverlight 2009-03-12

    I couldn't get this to work in Silverlight, so I created two test projects. One simple WPF project and one simple Silverlight project that both do only one thing: set a public static readonly variable in code, and use it in a completely bare bones XA

  • What are the reasons for preferring Singleton or function scope local static objects over one another? 2009-04-10

    Both Marshall Clines' "C++ FAQ Lite" and Scott Meyers' Effective C++ suggest using functions returning local static objects to avoid possible problems with non-local static object initialization order. In short (from "Effective C++", 3rd edition by S

  • C# Using block usage with static objects 2009-04-15

    I'm adding some code into a using block in a C# program. I'm sort of stuffing my app, which previously was a standalone into an existing body of code, so I need to do a bit of messing around to get it to fit properly. What it's ending up looking like

  • static constructors in C++? need to initialize private static objects 2009-07-28

    I want to have a class with a private static data member (a vector that contains all the characters a-z). In java or C#, I can just make a "static constructor" that will run before I make any instances of the class, and sets up the static data member

  • How can I create a static object member of class? 2009-08-29

    I am fairly new to c++, especially in its techniques. My question is, how can I create a static object member of a class itself. What I mean is I declared a static member object inside a class. Example: CFoo:CFoo *pFoo[2] = {0}; class CFoo { public:

  • C++ singleton vs. global static object 2009-09-23

    A friend of mine today asked me why should he prefer use of singleton over global static object? The way I started it to explain was that the singleton can have state vs. static global object won't...but then I wasn't sure..because this in C++.. (I w

  • Using static objects 2009-09-26

    My understanding is any method which does not modify state of the constaining class is a prime candidate to be made static because it does not touch the instance. An instance would be that containing class's data (fields/properties) so if I had a per

  • Arranging global/static objects sequentially in memory 2009-09-28

    In C++, is it possible to force the compiler to arrange a series of global or static objects in a sequential memory position? Or is this the default behavior? For example, if I write… MyClass g_first (“first”); MyClass g_second (“second”); MyClass g_

  • Crash at static object destruction 2009-12-28

    I am working on a 3rd party c++ app. It is crashing during the exit. If I look at the stack all I get is the __static_initialization_and_destruction_0 function and lots of questions marks. Project is huge and unfortunately it has many static objects.

  • Static objects in wpf app 2010-02-11

    In my wpf app i am using a lot of objects declared as static for caching purposes. Just wondering if there are any drawbacks. --------------Solutions------------- I almost never use static data, because of the inherent problems that come into play wh

  • Is it safe to access asp.net session variables through static properties of a static object? 2010-05-10

    Is it safe to access asp.net session variables through static properties of a static object? Here is what I mean: public static class SessionHelper { public static int Age { get { return (int)HttpContext.Current.Session["Age"]; } set { HttpContext.Cu

  • What is the correct way to synchronize a shared, static object in Java? 2010-06-09

    This is a question concerning what is the proper way to synchronize a shared object in java. One caveat is that the object that I want to share must be accessed from static methods. My question is, If I synchronize on a static field, does that lock t

  • How to do static de-initialization if the destructor has side effects and the object is accessed from another static object's destructor? 2010-06-29

    There is a simple and well-known pattern to avoid the static initialization fiasco, described in section 10.13 of the C++ FAQ Lite. In this standard pattern, there is a trade-off made in that either the constructed object gets never destructed (which

  • ASP.NET A static object to hold connection with a DB. Is it a good idea? 2010-07-20

    I'm wondering if it is a good approach in the ASP.NET project if I set a field which "holds" a connection to a DB as a static field (Entity Framework) public class DBConnector { public static AdServiceDB db; .... } That means it'll be only one object

  • (Non) Static Object in Loop 2010-09-03

    In a book there is an example about static/non-static objects. char buf[MAX]; long count=0; int i=0; while(i++<=MAX) if(buf[i]=='') { buf[i]='*'; ++count; } assert(count<=i); It is said that sometimes the code will write past the end of the buf

  • Static Object in Jboss using EJB3 2010-09-09

    is it possible to create something like static object using EJB3 in Jboss. in other words i need to create something like a static object using singleton pattern or something like that, that is because i need to preload a configuration from database

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.174 (s). 11 q(s)