objective-c

How can I cancel an in-progress undo/redo operation?

I've been tinkering with Cocoa for a few months now, and am trying to add undo/redo support to a strictly-for-learning-purposes Cocoa app I'm writing that lets you adjust iTunes track metadata. Thanks to NSUndoManager's prepareWithInvocationTarget: method, I have the basics in place — you can undo/redo changes to the Play Counts and Last...

Weird math in Objective C

I am getting an unexpected value with a simple math calculation in Objective C. I have output the three different parts of the calculation as well as the result of the calculation below. The following code NSLog(@"self.contentView.bounds.size.width: %f", self.contentView.bounds.size.width); NSLog(@"SWATCHES_WIDTH: %f", SWATCHES_W...

How to find if NSTimer is active or not?

I have a something like this: NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateCountdown) userInfo:nil ...

App crashes on fast exit+restart

I am working with a free app that calculates grades for norwegian high school students. The different subjects are stored in a sqlite database. Everything works fine, except for one thing: If i close the app and restart quickly (faster than, say, one second), it crashes. Also, this only happens if I close the app in specific circumstance...

Encountering display errors while using UIViewAnimationTransitionFlip

Hello I have 2 views, one login and another home. On clicking the signin button in my login view, on successful login, the user is redirected to the home view. Flip transition is implemented to acheive this. The problem is after the flip has occured, the home view layout is not displayed correctly. The view seems to drag itself above a ...

Accessing objects within objects?

I am a little confused about how I "set" and "get" the instance variables for an object that is contained within another. As you can see from the code below I first create a RocketBody which includes a SolidRocketMotor object. I am creating the SolidRocketMotor in RocketBody init and deallocating it in RocketBody dealloc. My question i...

Method Swizzle on iPhone device

I tried both JRSwizzle, and MethodSwizzle. They compile fine on the simulator but throw a bunch of errors when I try to compile for Device (3.x) Has anyone had any luck swizzling on the iphone? Whats the trick? TIA ...

Different ways to initialize singletons

Working in C# and Java, I've seen basically one way everybody initializes singletons: static obj _inst = null; obj getInstance() { if (_inst == null) { _inst = new obj(); } return _inst; } Now, when I move to Objective-C for the iPhone, whenever I see code samples, I see basically the same thing: static obj _inst = nil; +...

In Cocoa, how do you change the line endings of a file to LF?

Do I have to read the files and iterate manually? I'd like to be able to change between LF and CRLF. ...

Using NSArray's makeObjectsPerformSelector to have side effects

I have an NSArray of Foos in an Objective-C program. I would like to call the doIt function of each Foo, however, the makeObjectsPerformSelector function of NSArray does not allow the original Foos to be modified, per the docs. The doIt selector changes the m data member for each Foo when doIt is called. How do I go about efficiently per...

AES difference between iPhone (Objective-c) and Java

Hi all, I have been tearing my hair out all day trying to solve this... I have an objective-c client running on the iPhone, connecting to a Java server. The iPhone is encrypting data using AES but I cannot decrypt it on the server. I am using a known passphrase and message (single string) and am generating the byte array on the iPhone...

UIButton inside UITableViewController

I have a UIButton that is created inside of each table cell. I want to hook up a touch event like so: [imageButton addTarget:self action:@selector(startVote:) forControlEvents:UIControlEventTouchUpInside]; I want to pass data about the current row (the id of the object for that row) to the startVote method. Is th...

UITextView disabling text selection

I'm having a hard time getting the UITextView to disable the selecting of the text. I've tried: canCancelContentTouches = YES; I've tried subclassing and overwriting: - (BOOL)canPerformAction:(SEL)action withSender:(id)sender (But that gets called only After the selection) - (BOOL)touchesShouldCancelInContentView:(UIView *)view; ...

How LibXmlParsing can parse in chunks

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { xmlParseChunk(context, (const char *)[data bytes], [data length], 0); } my Question is as follows => didReceiveData: method receives data in parts Some what like this first data----------| <masterData>Main</ma second data-----| ster><maste...

scheduling a Thread after a Thread in iphone application

I want to schedule a thread after a thread completion. Is it possible ? How? For example ( to specify my need ) - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // 1. response - schedule myThread // 2. response - schedule a new thread which will be executed after myThread // 3. response - s...

Separating Code To Be Organized

I'm building a zipper application, but it has a declaration that I want to separate it in another file (compress-file.m), but only when I separate the files I got an error when compiling with a variable, see it: [ubuntu@eeepc:~/Desktop] make This is gnustep-make 2.0.2. Type 'make print-gnustep-make-help' for help. Making all for app Lea...

Open File Dialog Box

Hello, I'm learning Objective-C and trying to develop a simple zipper application, but I stopped when now, when I need to insert a button at my dialog and this button opens a Open File Dialog that will select a file to compress, but I never used a Open File Dialog, then how I can open it and store the user selected file in a char*? Than...

Subclassing UIView or composing with UIView

I'll start by saying what I want to do because I'm unsure if I'm asking the right question. I'm making a grid based map and am going to hold an array of objects to keep the state and presentation of the map. Each object will be of a Tile class. Should I be subclassing UIView or sublass NSObject and have an ivar of UIView. I was also plan...

Generating getters & setters in XCode

I am currently using xcode for some c++ development & I need to generate getters & setters. The only way I know is generating getters & setters in Objective C style something like this - (string)name; - (void)setName:(string)value; I dont want this; I want c++ style generation with implementation & declaration for use in the header fi...

What should I be reading for intermediate Cocoa programming instruction?

I'm looking for reading material to bridge the gap between "read Hillegass multiple times" and "productive Cocoa programmer". What materials do you suggest? I am not particularly looking for iPhone/Cocoa Touch resources, though if they are also relevant to Mac programming, I'd take a look. Edit: I do appreciate that there is no substit...