objective-c

Objective C - NSNumber, NSInteger, ...

What's the difference between NSNumber and NSInteger? Are there more primitives like these that I should know about/use? Is there one for floats? ...

iPhone dev - create array in init or viewDidLoad

In my UIViewController subclass should I initialize the NSArray of data for the UIPickerView in init or in viewDidLoad and why? Thanks. ...

Base64 encoding on the iPhone, works in simulator, breaks on device

Hi I am using the simple SMTP client code, first posted on google code at: http://code.google.com/p/skpsmtpmessage/ That repo seems to have gone unmaintained, as the project owner is now employed at apple, and maybe has better things to do. There is a fork of the code, that is more recently maintained at github, which you can find at...

iPhone Objective C: How to get a pixel's color of the touched point on an UIImageView?

iPhone Objective C: How to get a pixel's color of the touched point on an UIImageView, even if the parent UIView or itself is being rotated by the CGAffineTransformMakeRotation function? Will the view property of the UITouch still correctly return the correct pixel of the touched point even if the UIView/UIImageView is being scaled and ...

How to make a subview tint a portion of the screen on the iPhone?

I would like to write a UIView subclass that, among other things, colors whatever's underneath it a certain color. This is what I've come up with, but it unfortunately doesn't seem to work correctly: #import <UIKit/UIKit.h> @class MyOtherView; @interface MyView : UIView { MyOtherView *subview; } @end @implementation MyView - (id)...

NSString to Print in in binary format

Hi I dont understand of the below case of converting int to byte , the below java code can able to print the byte value as below System.out.println("binary output ::: "+Byte.toString(bo[0])); System.out.println("binary output ::: "+Byte.valueOf(bo[1])); System.out.println("binary output ::: "+Byte.valueOf(bo[2]));...

When i run my iPhone application it just show a white window, but when I press home button then it shows output what's wrong with it?

My piece of code is... window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; window.backgroundColor = [UIColor blackColor]; CGRect rect = CGRectMake(0,0,320,480); view = [ [ UIView alloc ] initWithFrame:rect ]; view.backgroundColor = [UIColor blueColor]; [window addSubview:view]; // Override point for customizat...

Storing a persistent CLLocation

I think I am missing something obvious somewhere. I have a (CLLocation *)lastqueriedlocation defined in the header as a property and synthesized. I want to updated it in locationManager:didUPdateToLocation:fromLocation: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CL...

How can I check if a struct has been initialized?

I'm using an NSRange (a struct) and initializing it like this: @interface MyViewController : UIViewController { NSRange currentRange; } NSRange has a location and length field. How can I check to see if the struct has been initialized with a value? I tried: if (myRange.length == nil) but the compiler complained about comparing...

hiding or adding a UIBarbuttonitem in tableview

Hello all , I have a question concerning hiding ,removing or adding a UIBarbuttonItem on UIToolbar. I have a UIToolbar and two items. I wish to hide an item on the toolbar and when I enter for example third UITableview it will appear. I've put this code in my viewDidload instruct = [[UIBarButtonItem alloc] initWithImage:[UII...

Can I detect if higher subview has been touched?

I've got a big UIView that responds to touches, and it's covered with lots of little UIViews that respond differently to touches. Is it possible to touch anywhere on screen and slide around, and have each view know if it's being touched? For example, I put my finger down on the upper left and slide toward the lower right. The touchesBe...

Does Objective-J support protocols like Objective-C?

I can't seem to find any documentation on the Objective-J language itself. Does it support @protocol like Objective-C? Is there a language spec somewhere I'm missing? ...

In Objective-C why should I check if self = [super init] is not nil?

Hey guys, I have a general question about writing init methods in Objective-C. I see it everywhere (Apple's code, books, open source code, etc.) that an init method should check if self = [super init] is not nil before continuing with initialisation. The default Apple template for an init method is: - (id) init { self = [super in...

Cancel out of UISearchBar when user taps on view

Does anyone know how to cancel (resign First Responder) out of a UISearchBar when you tap below the search text box and above the keyboard? Can anyone help post some code to handle this? Thanks ...

Fixing memory leaks in Cocoa/ObjC

I'm having a severe memory leak issue with my program. I'm using Apple's Instruments to track my leaks, and in the first few seconds after my app starts there are hundreds and hundreds of leaks listed. The problem is none of them seem to tell me where the leak is coming from. I've gone through all my classes and made sure that anything ...

How do i mock a method that accepts a handle as an argument in OCMock?

I'm trying to mock a method that has the equivalent of the following signature: - (NSDictionary *) uploadValues:(BOOL)doSomething error:(NSError **)error I want it to return a small dictionary so that my test can make sure the code uses the dictionary properly. however, no matter what i do OCMock always returns nil from the method, r...

Problem adding multiple annotations to map.

Ok, so I’m having this problem. What I want to do is manually add multiple annotations to a map. When I add just one annotation, it works flawlessly. The pin drops, you can click on it to see its callout, life is good. The problem comes when I want to add more than one. When I add the second, suddenly the pin’s aren’t coloured correctly...

Size discrepancy between size of folder from Finder and from Carbon file manager

Hi, I'm using this method by Dave DeLong to calculate the size of a folder using the Carbon File Manager API: http://github.com/davedelong/BuildCleaner/blob/b2712242b4eea1fff0e78a08b393a417e3019c8a/NSFileManager+FileSize.m (Its the first method there) The issue I'm having is that some folders (.app bundles in my case) are not reporti...

Array of pointers causes leaks

Hi I have this code -(void)setUserFilters{ //init the user filters array userFilters = [[NSMutableArray alloc] init]; SearchCriteria *tmpSc= [[SearchCriteria alloc] init]; for(int i=0;i<[searchFilters count];i++) { tmpSc=[self.searchFilters objectAtIndex:i]; if(tmpSc.enabled==TRUE) [userFilters addObject:tmpSc]...

Weird behavior of webView

I've got an app with a webview. It was working great, and then I moved the webView into an NSSplitView. Now it seems for some reason that whenever I press any key to enter text into the webview, it scrolls down. I haven't a clue as to what could cause this. Please help! ...