Search Results

Search found 6745 results on 270 pages for 'objective j'.

Page 5/270 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Objective-C Pointer to class that implements a protocol

    - by Winder
    I have three classes which implement the same protocol, and have the same parent class which doesn't implement the protocol. Normally I would have the protocol as pure virtual functions in the parent class but I couldn't find an Objective-C way to do that. How can I utilize polymorphism on these subclasses and call the functions implemented in the protocol without warnings? Some pseudocode if that didn't make sense: @interface superclass: NSObject {} @interface child1: superclass<MyProtocol> {} @interface child2: superclass<MyProtocol> {} The consumer of these classes: @class child1 @class child2 @class superclass @interface SomeViewController: UIViewController { child1 *oneView; child2 *otherView; superclass *currentView; } -(void) someMethod { [currentView protocolFunction]; } The only nice way I've found to do pure virtual functions in Objective-C is a hack by putting [self doesNotRecognizeSelector:_cmd]; in the parent class, but it isn't ideal.

    Read the article

  • Adding C++ Object to Objective-C Class

    - by Winder
    I'm trying to mix C++ and Objective-C, I've made it most of the way but would like to have a single interface class between the Objective-C and C++ code. Therefore I would like to have a persistent C++ object in the ViewController interface. This fails by forbidding the declaration of 'myCppFile' with no type: #import <UIKit/UIKit.h> #import "GLView.h" #import "myCppFile.h" @interface GLViewController : UIViewController <GLViewDelegate> { myCppFile cppobject; } @end However this works just fine in the .mm implementation file (It doesn't work because I want cppobject to persist between calls) #import "myCppFile.h" @implementation GLViewController - (void)drawView:(UIView *)theView { myCppFile cppobject; cppobject.draw(); }

    Read the article

  • Wishlist for Objective-C IDE/Xcode ?

    - by Null Pointer
    My company is evaluating the possibility of developing set of tools for Objective-C extending Xcode default functionality(basically we are thinking about providing better navigation,semantic search, more refactorings, quick fixes, improved code completion (visual assist inspired). So we would like to ask XCode/Objective-C developers: Do you feel that you are missing some features in XCode? What is your wish list? Are you considering the possibility of using addons to Xcode which are not created by Apple? Would you be willing to pay for these addons, or would you only consider free solutions?

    Read the article

  • Debugging Objective C JNI code

    - by thatidiotguy
    Here is the situation: I have a client's java project open in eclipse. It uses a JNI library created by an Xcode Objective C project. Is there any good way for me to debug the C code from eclipse when I execute the Java code? Obviously eclipse's default debugger cannot step into the jni library file and we lose the thread (thread meaning investigative thread here, not programming thread). Any advice or input is appreciated as the code base is large enough that following the client's code will be radically faster than other options. Thanks. EDIT: It should be noted that the reason that the jni library is written in Objective-C is because it is integrating with Mac OSX. It is using the Cocoa framework to integrate with the Apple speech api.

    Read the article

  • double checked locking - objective c

    - by bandejapaisa
    I realised double checked locking is flawed in java due to the memory model, but that is usually associated with the singleton pattern and optimizing the creation of the singleton. What about under this case in objective-c: I have a boolean flag to determine if my application is streaming data or not. I have 3 methods, startStreaming, stopStreaming, streamingDataReceived and i protect them from multiple threads using: - (void) streamingDataReceived:(StreamingData *)streamingData { if (self.isStreaming) { @synchronized(self) { if (self.isStreaming) { - (void) stopStreaming { if (self.isStreaming) { @synchronized(self) { if (self.isStreaming) { - (void) startStreaming:(NSArray *)watchlistInstrumentData { if (!self.isStreaming) { @synchronized(self) { if (!self.isStreaming) { Is this double check uneccessary? Does the double check have similar problems in objective-c as in java? What are the alternatives to this pattern (anti-pattern). Thanks

    Read the article

  • Use C++ with Objective-C in XCode

    - by prosseek
    I want to use/reuse C++ object with Objective-C. I have a hello.h that has the class definition, and hello.cpp for class implementation. class Hello { int getX() ... }; And I use this class in Objective-C function. #include "hello.h" ... - (IBAction) adderTwo:(id)sender { Hello *hi = new Hello(); int value = hi->getX(); NSLog(@"Hello %d", value); [textField setIntValue:value]; When I compile the code in Xcode, I get this error message. class Hello *XXXXX Users/smcho/Desktop/cocoa/adderTwo/hello.h:9:0 /Users/smcho/Desktop/cocoa/adderTwo/hello.h:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Hello' Q: What went wrong? Am I missing something?

    Read the article

  • XCode 3.2 - can't create Objective-C class

    - by Urizen
    My installation of XCode 3.2 has begun to exhibit some strange behaviour. When I try to add a basic Objective-C classs (inheriting from NSObject), in my iPhone project, I get the following popup: "Alert. Couldn't load the next page". The above-mentioned error happens at the point of trying to create the file (i.e. the creation process doesn't get to the stage where you are asked to input the file name). It might also be worth mentioning that where there previously used to be a description for the file (in the file creation window) it now states "No description available". I can create other files (e.g. UIViewController subclass etc.) but not the basic Objective-C class. I have updated the documentation and restarted the machine and xcode several times without success. I would be extremely grateful for any assistance as I am relatively new to the XCode environment.

    Read the article

  • how to extract only the 1st 2 bytes of NSString in Objective-C for iPhone programming

    - by suse
    Hello, 1) How to read the data from read stream in Objective-C, Below code would give me how many bytes are read from stream, but how to know what data is read from stream? CFIndex cf = CFReadStreameRead(Stream, buffer, length); 2) How to extract only the 1st 2bytes of NSString in Objective-C in iPhone programming. For Ex: If this is the string NSString *str = 017MacApp; 1st byte has 0 in it, and 2nd byte has 17 in it. how do i extract o and 17 into byte array? I know that the below code would give me back the byte array to int value. ((b[0] & 0xFF) << 8)+ (b[1] & 0xFF); but how to put 0 into b[0] and 17 into b[1]? plz help me to solve this.

    Read the article

  • Frustrated with Objective-c code...

    - by Moshe
    Well, I've started with iPod/iPhone programming using Head First iPhone Development (O'reilly) and I'm typing code out of the book. There are two problems, one is programming related and the other is not. I don't understand the format of objective-c methods. I'm getting an few errors now, based on source code from the book. Which leads me to my next issue. Some of the code is buggy. I think so because I couldn't get the code to run without modifying it. The book has some typos in the text since it's a first edition and whatnot, but could my "fixing" the code have to do with it? So... Where can I learn more about objective-c methods and how they work in terms of structure and where the return type and arguments go? For those with the book, I'm in the middle of the InstaTweet app towards the beginning. Thanks.

    Read the article

  • Importing Swift classes within a Objective-C Framework

    - by theMonster
    I have a custom Framework that has a bunch of Objective-C Classes. Within the Framework, I'd like to add more classes using Swift. However, when trying to expose the Swift classes to the Objective-C code using: MyProduct-Swift.h, it comes up as "MyProduct-Swift.h file not found". I've tried this in a single view template and it works fine. Is it not possible to import Swift within a framework? I've also verified that I have set the Defines Module setting and the Module Name. I've tried it with and without these settings.

    Read the article

  • Sorting an array of Objective-c objects

    - by davbryn
    So I have a custom class Foo that has a number of members: @interface Foo : NSObject { NSString *title; BOOL taken; NSDate *dateCreated; } And in another class I have an NSMutableArray containing a list of these objects. I would very much like to sort this array based on the dateCreated property; I understand I could write my own sorter for this (iterate the array and rearrange based on the date) but I was wondering if there was a proper Objective-C way of achieving this? Some sort of sorting mechanism where I can provide the member variable to sort by would be great. In C++ I used to overload the < = operators and this allowed me to sort by object, but I have a funny feeling Objective-C might offer a nicer alternative? Many thanks

    Read the article

  • Objective-C to Java cross compiler

    - by mvid
    It is clear that cross compilers will not be allowed by the Apple App Store, so a developer will need to be familiar with Objective-C to create applications for the iPhone. I was wondering, is there a cross compiler that will take Objective-C application code and rebuild it into a similar Java application that can be packaged for Android? That way, a developer could still learn just one language (obj-c) but put out applications on many devices. I understand that the Java port would be less optimal than a natively coded application, but could conceivably save a developer some time.

    Read the article

  • objective-c default init method for class?

    - by Alex
    Hello, I have two differing methods for initializing my objective-c class. One is the default, and one takes a configuration parameter. Now, I'm pretty green when it comes to objective-c, but I've implemented these methods and I'm wondering if there's a better (more correct/in good style) way to handle initialization than the way I have done it. Meaning, did I write these initialization functions in accordance with standards and good style? It just doesn't feel right to check for the existence of selfPtr and then return based on that. Below are my class header and implementation files. Also, if you spot anything else that is wrong or evil, please let me know. I am a C++/Javascript developer who is learning objective-c as hobby and would appreciate any tips that you could offer. #import <Cocoa/Cocoa.h> // class for raising events and parsing returned directives @interface awesome : NSObject { // silence is golden. Actually properties are golden. Hence this emptiness. } // properties @property (retain) SBJsonParser* parser; @property (retain) NSString* eventDomain; @property (retain) NSString* appid // constructors -(id) init; -(id) initWithAppId:(id) input; // destructor -(void) dealloc; @end #import "awesome.h" #import "JSON.h" @implementation awesome - (id) init { if (self = [super init]) { // if init is called directly, just pass nil to AppId contructor variant id selfPtr = [self initWithAppId:nil]; } if (selfPtr) { return selfPtr; } else { return self; } } - (id) initWithAppId:(id) input { if (self = [super init]) { if (input = nil) { input = [[NSString alloc] initWithString:@"a369x123"]; } [self setAppid:input]; [self setEventDomain:[[NSString alloc] initWithString:@"desktop"]]; } return self; } // property synthesis @synthesize parser; @synthesize appid; @synthesize eventDomain; // destructor - (void) dealloc { self.parser = nil; self.appid = nil; self.eventDomain = nil; [super dealloc]; } @end Thanks!

    Read the article

  • How to do pointer work with accessor methods in Objective-C

    - by Jasconius
    Basic problem statement: I have a very good reason for doing some pointer fanciness in an app where I need to pass a decimal by reference. So I have a class which stores many a decimal, so let's say is has a property as such: @property (nonatomic) double myDecimalValue; I want to pass it by reference to some other class. [someOtherObject sendMyDecimalByReference:&myDecimalValue]; But, a problem emerges! The way that actually has to be written (because it's a property) is [someOtherObject sendMyDecimalByReference:&decimalOrigin.myDecimalValue]; This fails to compile in objective-c I get around it by writing the following - (double *) myDecimalValueRef; [someOtherObject sendMyDecimalByReference:[decimalOrigin myDecimalValue]]; Except I have dozens of these decimals and I don't want to write that stupid wrapper function for every value. Is there a shorthand way to do this in Objective-C using just the Getter functions? Let's just assume I have a great reason for not using NSNumber. Thanks!

    Read the article

  • Using OpenGL Mathematics (GLM) in an Objective-C program

    - by user1621592
    i am trying to use GLM to load a .obj object in my Objective-C Program (Xcode 4.4 Mac Os X). I have added the glm folder to my project. i try to import it using #import "glm/glm.hpp", but the program doesn't build. some of the errors are the following: (this errors are produced in the GLM files) namespace glm{ //Unknown type name 'namespace' namespace detail { ..... it doesn't find the cstdlib, cmath, and other libraries.... This happens because my program is in Objective-c and the GLM doesn't work with this language??? How can i resolve this problem??? Thanks for your help.

    Read the article

  • iPhone Objective-C/Plain C Memory Management

    - by toc777
    Hi everyone, I understand Objective-C memory management but I'm using Core Graphics functionality such as CGRect, CGPoint, CGImageRef etc.. which is written in plain C. My question is how do i manage this memory or is it already handled for me? According to the Apple documentation if an Apple Objective-C function doesn't have copy, new or create in it the returned object is managed for you using autorealease. Is this true for the Core Graphics stuff also? (Well i guess it wont be using autorealease but maybe something similar?) Thanks for taking the time to read this.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >