objective-c

Why is my value passed through NSNotifcationCenter not preserved?

I'm trying to send a CGPoint through an NSNotification like this -(void)setPosition:(CGPoint)point { NSString *pointString = NSStringFromCGPoint(point); NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"p", pointString, nil]; [[NSNotificationCenter defaultCenter] postNotificationNa...

NSCollectionView draws nothing

I'm trying to set up an NSCollectionView (I have done this successfully in the past, but for some reason it fails this time). I have a model class called "TestModel", and it has an NSString property that just returns a string (just for testing purposes right now). I then have an NSMutableArray property declaration in my main app delegat...

Why is my transformable Core Data attribute not using my custom NSValueTransformer?

I have a Core Data app with a fairly simple data model. I want to be able to store instances of NSImage in the persistent store as PNG Bitmap NSData objects, to save space. To this end, I wrote a simple NSValueTransformer to convert an NSImage to NSData in PNG bitmap format. I am registering the value transformer with this code in my Ap...

retain will allocate Memory in RAM?

the follwing will allocate memory in RAM ....? NSArray *obj = [[NSArray arrayWithObjects: @"Hai", @"iHow", nil] retain]; ...

how to show google maps using uiwebview with zooming in uiwebview?

as we all know that driving direction is not supported in mapkit.so i think i can show driving direction in webview.i am showing google maps in uiwebview,but it shows the whole site i just want to show only map part with some zoom so that it looks like original maps application of iphone.also i don't know if this breaks the apple's Human...

Language Based Scanning in a UILabel

Hello, I'm developing a twitter client (YES, another one) for the RTL languages. How can a UILabel alignment be configured depending on the language of a tweet. So if language of the tweet is Arabic for example the alignment would be UITextAlignmetRight and vice versa. ...

how to record video and save to documents directory iphone sdk?

i want to detect if the phone is 3gs then record the video and save to documents directory.and then play movie by picking url from documents directory.note i do not want to save video to savedphotoalbum so that user not be able to delete video.also is there a way i can save video to database ...

(iphone) when or how to get the uiview height size after layoutSubviews

in my viewcontroller I make my instance of my view class ( in the viewdidload method) in that view class I implement the layoutsubviews method and add all kinds of subviews there now since that view class is part of a uiscrollview i want to make the scrollview contentsize as large as the view class how do i get the height of my viewcla...

Using Protocol Buffers with Objective-C

Has anyone used Google's Protocol Buffers when developing applications in Objective-C? Are there any current projects for compiling .proto files into Objective-C, all the Google docs simply refer to Java, C++ or Python. ...

NSDateFormatter returns 1970 instead of current year with format MM/dd

The following code: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"MM/dd"]; NSDate *newTime = [dateFormatter dateFromString:@"10/01"]; sets the resulting date to 10/01/1970. Is there a "right" way to have the formatter assume that you mean a date in the current year, or c...

Don't expose symbols from a used library in own static library

I am writing a reusable static library for the iPhone, following the directions provided here. I want to use minizip in my library internally, but don't want to expose it to the user. It should be possible for the user to include minizip themselves, possibly a different version, and not cause clashes with my "inner" minizip version. I...

View selector return value when debugging in Xcode

I am running through an iPhone development tutorial and I have a weird bug that I am investigating using the debugger. I have the following code that checks to see if a object is in bounds. I am trying to see what the value of ball.center.x is at a certain point, but because center is a property accessor selector, I don't get the value...

Optimizing A* Pathfinding iPhone - Will NSDictionary do the trick?

I've got a pretty big A* pathfinding function that gets called frequently and has to be put in another thread because otherwise it will make my game stutter. I come from a Java background, and recently read a discussion about the speed of HashMap's (essentially the equivalent of NSDictionary) and the different implementations you can use...

How to create an Array of Strings in Objective c for iphone

I'm trying to create an array of strings that can be randomized and limited to a certain x number of strings. If the array could be randomized I could pick the first x strings and that would work fine. I'm trying to use code like this currently NSString *statements[9]; statements[0] = @"hello"; This seems to work but the array seems...

How to monitor global modifier key state (in any application)?

I'm using some Carbon code in my Cocoa project for handling global key events (shortcuts) from other applications. Currently I have setup a kEventHotKeyReleased event handler and I can successfully obtain hot keys when my application is not active. That triggers some operation in my application. The problem I have with the behavior of k...

Cocoa-Touch: UITableView not resizing

I have an app, which has a top navigation bar and a bottom tab bar. One of the tabs displays a table's XIB file with my custom controller. This UITableView is created by a MyTableViewController class. I have a problem with the table's size. The table's frame size is bad (it's the fullscreen iphone size, without the status/tab/navigat...

Why is Xcode reporting a "defined but not used" warning for my class variable?

I am getting a warning on this line in my header, but I am using the class variable in my implementation (in both class methods and instance methods): #import <UIKit/UIKit.h> static NSMutableArray *classVar; // Xcode warning: 'classVar' defined but not used @interface MyViewController : UIViewController { ...

What are AppDelegates in Objective-C?

I'm working through an iPhone tutorial (link text and it has me put in some code (a few times throughout the various tutorials) but it doesn't explain it at all. In this code: todoAppDelegate *appDelegate = (todoAppDelegate *)[[UIApplication sharedApplication] delegate]; What exactly is an appDelegate? What does the "delegate" at the...

What would you do instead of using NSViewController to be compatible with 10.4?

All I need to do is load and swap some nibs in a NSView of a window. I know how to do it with NSViewController and have it working perfectly with 10.5-10.6, but I don't know what to do for 10.4. Tutorial links very welcome, I have trouble finding legacy stuff. (Yes, I really do need to support 10.4.) ...

NSCFArray mutated while being enumerated - but I don't use enumerators

One thing I really don't like about Objective-C is that it's very difficult to find out what's going on under the hood. The latest problem this has caused me is a random exception that occurs in random places in my code and breaks everything - it's the one listed above, about concurrency problems with NSArray. The thing is that I never...