objective-c

UIScroll view current position in iphone

Suppose I have a scroll view in a view & a scroll view's size is 320 width, 2000 height. When user scrolls & decelerating stops, I want to know where a scroll view has stopped? i.e. at 300px or 400px or at 600px. Thanks in advance. ...

preprocessor debug macro for optional logging

I'd like to code in some preprocessor macros to optionally log some information. For example in the .h //#define ML_DEBUG(x) (x) // flip this bit to do the error logging #define ML_DEBUG(x) (1==1) // flip this bit to silence in the .m I implement like: ML_DEBUG(NSLog(@"Class dealloc: %@", [NSString stringWithCString:object_getClass...

NSScroller graphical glitches/lag

Hi, I have the following NSScroller subclass that creates a scroll bar with a rounded white knob and no arrows/slot (background): @implementation IGScrollerVertical - (void)drawKnob { NSRect knobRect = [self rectForPart:NSScrollerKnob]; NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y, knobRect.size.width - 4, ...

ScrollOffset in UIWebView?

Hello, I'm having a really hard time understanding delegates and object inheritance (if I may use this word) and I think I need a simple (or so I think) thing: catch scrollViewDidScroll event in UIWebView and get offset (basically, just to know if scroll is not on top/bottom, so I could hide navigation and tab bars). Is there any way I...

Storing identical data efficiently in a Core Data data model

I have a data model that contains several entities, each with several different attributes that store image data. These will all be small images and I need to store them in the persistent store rather than as external files. While I can just store the image data in a Binary or Transformable attribute, it's quite likely that the user wil...

Bluetooth Example Code for Cocoa (Objective-C)

I'm looking for example code for setting up a connection to a bluetooth device using the Bluetooth API in Cocoa. Apple used to include this type of example code in the XCode tools package under the /Developer/Examples/Bluetooth folder, but upon downloading the latest version of XCode (3.2.1), these bluetooth examples have been removed f...

How to Properly set an integer value in NSDictionary?

The following code snippet: NSLog(@"userInfo: The timer is %d", timerCounter); NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:timerCounter] forKey:@"timerCounter"]; NSUInteger c = (NSUInteger)[dict objectForKey:@"timerCounter"]; NSLog(@"userInfo: Timer started on %d", c); produces output along th...

iPhone One controller, multiple views

Hi I'm rather new to iPhone development, and am wondering how to load multiple views from a single controller. I come from a c# background and still trying to get my head around how things work in ObjC and the iPhone worlds. As a basic example of what I am trying to achieve, lets say I have a ClockController, the clock controller has ...

Objective C - Problem with NSMutableArray and NSTableView

I have a class named Person and in this class is the property PersonName (amongst others). A MutableArray MyUserInfoArr contains many Person objects. I want to list each PersonName in a Cell of a TableView? How do I do this? Thanks in advance. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath ...

how to show default user location and a customized annonation view in map kit?

i am using map kit and showing customized annonation view.one is carImage and the another one is userImage(as current location of user).now i want to show current user location default which is provided by map kit.but unable to show it.how do i show blue circle+my car in map kit? ...

Objective-C/iPhone Memory Management Static Variables

I have a static method that creates an instance of the class and puts it in the static variable. I am wondering what the proper way of memory management is in this situation. You can't put it in the dealloc-method, because although it can access the static variable any instance method that is created that get's released will also relea...

Apple Magic Mouse Api

Hi all, I just bought a Magic Mouse and I like it pretty much. But as a Mac Developer it's even cooler. But there's one problem: is there already an API available for it? I want to use it for one of my applications. For, example, detect the user's finger positions, swipe or stretch gestures etc... Does anyone know if there's an API for...

how to show mapkit blue dot(user's location) at desired location?

i am using map kit.i want to know that how we can get current user location.the mapkit shows blue dot at current user location.i want to do something like this.the user location is showed on map.i have button which on clicking again get the current user location and shows the blue dot there.do i need to use location manager.or just call ...

One code base for Snow Leopard and Leopard

Background I'm a developer who's in the throes of building an application for the Mac. I'm about to get my hands on Snow Leopard. Until now I've been building on Leopard. I've only been doing Cocoa development for about a year not very intensely. I've read a lot about Snow Leopard and Grand Central Dispatch in particular. I'm aware tha...

cellForRowAtIndexPath not called; sections returns 1 and rows returns 4

After parsing JSON data in a Data class, I set the UIViewController's NSArray *headlines property in a fillArrays method of the same Data class. In the viewDidAppear method of my UIViewController, I call reloadData on my UITableView. numberOfSectionsInTableView fires and returns 1, then numberOfRowsInSection fires and returns an array co...

a doubt regarding iphone memory management 'release'

- (void)applicationDidFinishLaunching:(UIApplication *)application { // Create the navigation and view controllers RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *aNavigationController = [[UINaviga...

Is it bad practice for a delegate to have a reference to the object for which it is the delegate?

I'm using the delegate pattern for one of my objects. My idea is that I will be able to swap the delegate out later for a different delegate implementing a different strategy. I suppose this is just as much the strategy pattern as the delegate pattern. My question is, is it bad practice for my delegate to have a reference back to the ...

sequencing UIImageView frame(s) animation & CGTransform animation

I'd like help on some strategies to sequence some animations. I subclassed UIImageView so that I could write some custom animation actions on an image. I implemented a few methods to be used as actions that I could call on my image example: -(void)rotateAnim; //rotates the image by a few degrees using a CGAffine Transform -(void)num...

Objective-C address book

I have two Objective-C classes that inherit from the UIViewController and am trying a different approach at learning how to interact with the iPhone's address book. The example Apple provides assumes that everything is in one class, but this isn't the way I need it done. My objective would be to have the address book view close after a p...

What's the CFString Equiv of NSString's UTF8String?

I'm stuck on stoopid today as I can't convert a simple piece of ObjC code to its Cpp equivalent. I have this: const UInt8 *myBuffer = [(NSString*)aRequest UTF8String]; And I'm trying to replace it with this: const UInt8 *myBuffer = (const UInt8 *)CFStringGetCStringPtr(aRequest, kCFStringEncodingUTF8); This is all in a tight uni...