objective-c

Is "self" necessary?

Is using "self" ever necessary in Objective-C or maybe just a good practice? I have gone from using it all the time to not using it at all and I don't seem to really notice any difference. Isn't it just implied anyway? ...

How can I check the content of the arrays? Parsing XML file with ObjectiveC

I have 3 classes-> video { nameVideo, id, description, user... } topic {nameTopic, topicID, NSMutableArray videos; } category {nameCategory, categoryID, NSMUtableArray topics} And then in my app delegate I defined-> NSMutableArray categories; I parse an XML file with this code. I try the arrays hierachy, and i think that i d...

How do I MOVE a circle drawn in a subclass of UIView by overwriting the method "drawRect"??

hi, I'm trying to figure out what i'm doing wrong but i just don't get it. Here is what i want to do: I want to draw a circle somewhere on the screen of the iphone and then i want the circle always to be displayed at the position where the user currently taps on the screen. I started by creating a subclass of UIView and adding the follo...

Are class methods convenience methods i.e. part of the framework

Are class methods convenience methods i.e. part of the framework e.g. +(id)alloc and instance methods are those that were implemented by the developer? I can't seem to understand the difference between instance methods and class methods. ...

How to get multiple copies of a UIView loaded from a nib?

I want to use a UIView heirarchy multiple times (the nib object is a template). Unfortunately, UIView does not conform to <NSCopying> so [cell.contentView addSubview: [[templEditCellView copy] autorelease]]; does not work. I wasn't surprised, since I want a deep copy of the view heirarchy. Currently the view is one of several top-le...

Can you declare a variable type that both expects a class and protocol in objective-c?

I know that you can do one of the following things when declaring the type of a variable in objective c: id obj0; MyClass *obj1; id<MyProtocol> obj2; What i'm curious about is if this is valid (syntactically and semantically): MyClass<MyProtocol> *obj3; What i want is to store a cocoa class that must implement a given protocol in t...

Setting up an independent delegate?

Its common for the dataSource and delegate to be the same object, its also common for this object to be the viewController. In all the info/tutorials that I have seen online delegates are always setup as above. If I wanted to create my own class instead can anyone give me any pointers as to how I might do that. Where does that...

Why is the CoreData stack in XCode's CoreData enabled template treated as private?

In regards to XCode templates with CoreData enabled, I've read http://stackoverflow.com/questions/2729055/unclear-use-of-property-in-window-app-using-core-data which goes over the 'what' in the templates. But I am having an issue with the 'why'. By declaring the category in the implementation file, the CoreData accessors act like private...

A little help with MVC

Hi everyone, I'm working on a cocoa app for syncing data between two folders. It have profiles (so you can have multiple setups) It's possible to analyze data It's possible to sync the data Im a little confused. First of all i cant really see where to have a model? And how many controller would you suggest? 1 WindowController or Ana...

Poblem with "CFDataRef".

Hello I have a problem with "CFDataRef. I get the "data" field from a "kCFSocketDataCallBack. "data" should correspond to a string received on the socket. How do I convert, for example, in a NSString so I can put my text in a textbox?? Thank you very much static void AcceptDataCallback(CFSocketRef s, CFSocketCallBackType type, CFDat...

"Infinite Drill-down" with UINavigationController

Can anyone suggest an article or perhaps an example of how to create an "infinite drill-down" with UINavigationController like you see in the Facebook, IMDB and BrightKite apps? ...

How can I make image brighter (more light as flash effect) using Core Graphics

How can I get flash effect for images got from Camera? After I got image from camera (it shows in UIImageView) and before saving it as a file I'd like to lighten (in some cases) image by pressing Flash button. Is it possible by using Core Graphics ?? ...

Handling out of memory errors in iPhone

I would like to handle out of memory errors in iPhone to execute logic with lesser memory requirements in case I run of of memory. In particular, I would like to do something very similar to the following pseudo-code: UIImage* image; try { image = [UIImage imageNamed:@"high_quality_image.png"]; } catch (OutOfMemoryException e) { ...

How to determine if an application is using the GPU

I'm looking for a way to determine how to know whether an application is using the GPU with Objective-C. I want to be able to determine if any applications currently running on the system have work going on on the GPU (ie: a reason why the latest MacBook Pros would switch to the discrete graphics over the Intel HD graphics). I've tried ...

JSON in COCOA (with YAJL)

at first, sry for my english... :) I'm using the YAJL Framework http://github.com/gabriel/yajl-objc My file look like this: [ [ 3753700, { "altitude" : 36950, "heading" : 129.918421384319, "latitude" : 47.554033252495699, "longitude" : 8.2125612837369903, "pointType" : "EXTRAPOLATED", "speed" ...

How can I get a CGImageRef from a file?

So I know you can get a CGImage from a file using UIImage... UIImage *img = [UIImage imageNamed:@"name.bmp"]; [img CGImage]; But, is there a way to get a CGImageRef without using a UIImage? (I am trying this in a static library which doesn't have access to UIKit) I could use other frameworks if necessary, just not UIKit. Would CIImag...

Are the iPhone media playback control window available to other applications?

what is the transparent modal window that has the playback controls in the music player (iPod) of the iPhone? how can i use it in my app? ...

What constitutes a private API in an iPhone app?

I'm fairly new to Objective-C and am confused on what falls under the unbrella of a "private API" that could cause Apple to reject my app. Does this include adding methods to existing classes? For example, I found some code on stackoverflow to recolor the tab bar icons for UITabBars with this extension to the UITabBarItem class. Is this ...

Code formatting when using pointers

Is there any reason why the asterisk is next to the object type in this code? I'm a little confused by the way I see this used. Some times it looks like this: NSString* stringBefore; and sometimes like this: NSString *stringBefore; Is there a difference? Or a right or wrong way to do this? Thanks ...

Convert a NSString

My situation is explained in the code below. I need to send via a socket NSString drawn from a TextBox Thank you very much NSString *string = fieldTesto.txt; // I Find an istruction for insert s string in to the CFSocketSend UInt8 message[] = "Hello world"; CFDataRef data = CFDataCreate(NULL, message, sizeof(message)); CF...