objective-c

Change UITabBarItem Tent Color on iPhone

Duplicate: Custom colors in UITabBar The iPhone UITabBar generally uses a blue and gray icon scheme. However, the iPod Touch ships with an application from Nike that has a red icon overlay, as opposed to the blue overlay. Here's a screen shot: Image Link How do I do that? Do I use the hidden setSelectedImage method in UITabBar...

architecting a visual grid of 'buttons'

I'm trying to design how to implement a relatively simple application. I want to create a grid of 'squares' that cover an entire screen. Each square should have the ability to respond to touch events, and then have an on/off state. For example, if I touch an 'off' square, and then drag my finger across 10 other squares, I want them ...

Using a constant NSString as the key for NSUserDefaults

I'm using NSUSerDefaults to store user preferences. I remember reading somewhere that setting the keys as constants is a good idea - and I agree. The following code is what I currently have: [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:polygon.numberOfSides] forKey:@"polygonNumberOfSides"]...

Subviews not showing up in UIView class

I'm trying to lay out some images in code using addSubview, and they are not showing up. I created a class (myUIView) that subclasses UIView, and then changed the class of the nib file in IB to be myUIView. Then I put in the following code, but am still getting a blank grey screen. - (id)initWithFrame:(CGRect)frame { if (sel...

Arrays of structs or native data types in Objective C

I've run into this problem a couple times now. Last time, I wanted to create an array of arrays (matrix) of BOOL's. I ended up encapsulating them in NSStrings, because apparently NSArray only has arrays of objects. This time, want an array of arrays again, but of CGPoints. I'm going to be using these to draw images to the screen...

What is the best way to implement syntax highlighting of source code in Cocoa?

I'm working on Cocoa Application that should be able to analyze and highlight a source code written in such languages as Objective-C, SQL, JavaScript, Python etc. The text should be editable too (by using NSTextView, for example). Please advise what is the best way to implement such feature in Mac OS X 10.5. There is no need to support...

Get an object attributes list in Objective-C

How can I get a list (in the form of an NSArray or NSDictionary) of a given object attributes in Objective-C? Imagine the following scenario: I have defined a parent class which just extends NSObject, that holds an NSString, a BOOL and an NSData object as attributes. Then I have several classes which extend this parent class, adding a...

UITableView

Duplicate: can i use highlighted the table view cell without default blue color in objective c? How can I change the default blue color when selecting the row of UITable? ...

how can i connect iphone library with my iphone application?

I want to doing a project where i need to connect to iphone music library. When my application is start music file is add my application and play when i want. ...

Releasing NSData causes exception...

Hi, Can someone please explain why the following code causes my app to bomb? NSData *myImage = UIImagePNGRepresentation(imageView.image); : [myImage release]; If I comment out the 'release' line, the app runs... but a few times calling the function containing this code and I get a crash - I guess caused by a memory leak. Even if I...

How do you programmatically get the serial number of an iPhone?

I want to know the serial number of my iPhone using my application. I have writen code below. - (NSString*)getSerialNumber { CFTypeRef serialNumberAsCFString; io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); if (platformExpert) { serialNumberAsCFStr...

Objective-C sample code for HMAC-SHA1

I need to generate HMAC-SHA1 in Objective C. But i didnt find anything that works. I tried with CommonCrypto, using CCHMAC, but didnt works. I need to generate a hmac and after generate HOTP number. Somebody have any example code in Objective C or C? ...

Is this an objective-c memory leak?

I know that if you do the following you most certainly have a memory leak: id foo = [[NSObject alloc] init]; foo = nil; But, what if you're using self.foo, a property with retain? And your code instead looks like the following: foo = [[NSObject alloc] init]; self.foo = nil; Is that still a memory leak since the accessor releases th...

Is there an iPhone SDK API for twitter?

mobclix.com has an API for integrating with facebook.com. Is there something similar for twitter.com and other social services? Meaning, these will look like native parts of your app? ...

Objective C strip out whitespace from NSString

How do I strip out the white space chars from an NSString ? Consider the following example: NSString *tmpString = @" Hello this is a long string! "; I want to convert that to: "Hello this is a long string!". I have tried a function like this, but it's not working: -(NSString *)cleanupString:(NSString *)theString {...

How unit testing a singleton in obj-c?

I have a singleton class, and can't unit test their code. I have test like: Db *db = [[Db alloc] initWithName:@"sample.db"]; [db createDb]; STAssertEquals([db existDb],YES,@"The db is not created!"); But only work the first. When the second is executed, I always get "null" from the initWithName method. When I remove the singlet...

Best Book or Article to learn iphone development

i am new to iphone development.. so from where i should start learning... pls tell me step by step to guide ...

[iPhone] Objective-C array of objects misbehaving (EXC_BAD_ACCESS) in TableViewController

Hello stackoverflow. I'm new to Objective-C, and I can't figure out why the NSString objects in my array of Car objects seem to have been released. Here's my Car.m class: #import "Car.h" @implementation Car @synthesize categoryId; - (id)initWithPrimaryKey:(NSInteger)pk categoryId:(NSNumber *)catId carName:(NSString *)n { if (self...

iPhone / Objective C nested C structures

Hi, Can someone confirm that nested C structures are NOT allowed in objective C. And by nested structs, I mean the following; struct Tex2D { GLfloat u; GLfloat v; }; // quad uv cords struct TexQuad { Tex2D uv[4]; }; I seem to have all kinds of problems compiling this. It's difficult to find any documentation on this as ...

How to add an object to a programatically bound NSMutableArray?

I have an NSDocument which has the following structure: @interface MyDocument : NSDocument { NSMutableArray *myArray; IBOutlet NSArrayController *myArrayController; IBOutlet MyView *myView; } @end I instantiate the NSArrayController and the MyView in MyDocument.xib, and have made the connections to the File's Owner (MyDoc...