objective-c

cocoa Document-based applications

I am building a simple document-based application in cocoa and I'm having problems to link common data between my document instances. I'd like to have some sort of AppController and have all my documents to access the same instance of this class. Instancing the object in document.xib will create different instances for each document. A...

Can I encode a subclass of NSManagedObject?

This is for an iPhone App, but I don't think that really matters. I need to send a custom object (which is managed by Core Data) over bluetooth using the iPhone's GameKit. Normally, I would just use an NSKeyedArchiver to package up the object as a data object and ship it over the line, then unarchive the object and I'm done. Of course, I...

Default.png won't display, iPhone

I have a really standard splash screen, just a simple Default.png, but for whatever reason, no matter what I try, it simply will not load. Is there any way to fix this and/or a way to set a property in tw info.plist to directly call a custom image? Thank you! ...

Removing MKMapView Annotations causes leaks.

I've boiled a very complex set of web services and searches down to the simple following code. I need to be able to add annotations to a map in response to a search (or in the sample below to the click of a button), then allow the user to click the button again and get a new set of results. In reality there will be a different number, ...

Text View font type & size in iphone

hi i am using below code to change the the font type of text view. but its not changing the font textView3.font = [UIFont fontWithName:@"Helvetica" size:17.0f]; tell me where i am wrong. ...

iPhone networking problems

Hi, i'm having trouble to asatblish a CFSocket connection to a java server from iphone. Server is listening on port 80. Wireless LAN connection works great. EDGE NOT (T-Mobile) One Strange thing: If i first go to safari and open a website which address is my server ip and then start the app it connects. Please help me! I'm really ha...

SubViewOneController’s view not appearing (Obj-C)

Hi everyone; I am trying to find my way into Obj-C (iPhone) following this tutorial. Unfortunately there must be something missing in the code because the view of SubViewOneController does not appear. Someone proposed a fix to this in the comments: "The solution to the SubViewOneController’s view not appearing is that you need to tell ...

Is MKMapView leaky

As well as my question "Removing MKMapView Annotations causes leaks." I have discovered that if you create a view based project, add a UISearchBar and MKMapView into the view's NIB, wire up the delegates (I'm not creating any methods as we don't actually need to do anything to trigger the leaks), link in the MapKit and fire up the proje...

UITextView detecting text using RegEx

I have a UITextView where users can type text. I want to parse HTML Links (Domains with or without http://) and Phone Numbers from the users after they click on the button. I know I can set the editable property of UITextView to NO to automatically parse links but I don't have the option to make it editable=NO and I want to parse the Li...

Access methods and properties of arbitrary Objective-C object from JavaScript.

I want to access properties and call methods of an Objective-C object that was returned to JavaScript host as property of exposed object ([windowScriptObject setValue:self forKey:@"a"]): - (id) valueForUndefinedKey:(NSString*) key { if ( [key isEqualToString:@"b"] ) { MyObject* obj = [ [ MyObject alloc ] init ]; return obj; ...

How to get the name or signature of the current method into an NSString?

Example: I have a method -myFooBarMethod:withFoo:bar:moreFoo: and inside the implementation of that method I want to dynamically get the name of it, like @"-myFooBarMethod:withFoo:bar:moreFoo: into an NSString. No hard-typing of the method signature. I feel that this has to do something with selectors. How could I get the name of the c...

How to find out who is the caller of a method or function?

I want to write a debug function or method that will help print useful information. When it is called, I need: the memory address of the calling object (if called by an object) the method signature of the caller (or the name of the method), or the name of the function the class name that owns that method or function Is it possible to...

SubViewTwoController not declared (obj-c)

Hi everyone, I am trying to find my way into Obj-C for iPhone programming using this tutorial. In the end, what ever menu point you choose, SubViewOne was displayed. I want to change this and in the end SubViewTwo(.xib) should appear when tapping the menu point "Sub View Two" So what i did was changing the second repeat of SubViewOn...

How to create a macro with multiple lines of code?

I want to make a macro which will inject some code, like: if (foo) { [Bar fooBar]; } and then, where ever I need that, I put FOOBAR in the code. Not sure, but at compile time then the compiler replaces this with the actual code like in the example above. Maybe there's something different than a macro I could use for this? ...

Why don't the Children in my dictionary fill up ...

Hello all I'm using NSXMLParser to parse some xml data. I'm using this data to build a Tree representation to create a hierarchy for a drilldowntable. - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary...

Is there an equivalent to C++'s dynamic cast in Objective-C ?

If I have two classes, SubClass and SuperClass: SuperClass *super = new SuperClass(); SubClass *sub = new SubClass(); SubClass *sub_pointer; // **The nice one-line cast below** sub_pointer = dynamic_cast<SubClass*> super; // Prints NO printf("Is a subclass: %s\n", sub_pointer ? "YES" : "NO"); sub_pointer = dynamic_cast<SubClass*> sub;...

Easy question: What does it mean if a variable is highlighted in red in the XCode debugger?

I'm having some trouble squashing some bugs in my iPhone application and I have come to the realisation that I'm not entirely clear on what the significance of a variable being highlighted in red? Does it mean the variable no longer exists? ...

Using iPhone OS 3.0 features if available, and 2.1 features if not, in one executable

Hey guys, I've seen apps on the iPhone that if running on 3.0 will use 3.0 features/APIs such as the in-app email composer, and if running on 2.x not using those features, and exiting the app to launch Mail instead. How is this done? My initial thoughts were to use #ifdef __IPHONE_3_0 but that will only work if I actually build the...

Most efficient way to draw individual pixels in OpenGL ES (Cocos2d-iphone)

I'm writing a flood-fill algorithm...it needs to paint individual pixels. What's the fastest way to do this? At first I thought of using cocos2d's drawpoint, but having 320 * 480 vertices doesn't sound too good. Is there a faster way using memset or something? ...

Good resources for learning Objective-C

I have developed for a number of years in Java, primarily for Linux and Windows. During my undergrad and grad school times, I also did quite a bit in C and C++. I have recently (in the last year and a half) started using primarily Apple computers at home, and am interested in exploring their Xcode development environment. I am interes...