objective-c

NSTimer not stopping

I have a Class with a NSTimer *myTimer; variable. At some point I do: myTimer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(doStuff) userInfo:nil repeats: YES]; further, I have a method: - (void)doStuff { if(myTimer) { //do stuff } } and I stop my timer when the class is released through: ...

Creating a nested set with sqlite and Objective-c

I was struggling with nested sets, specifically building one on the iPhone using sqlite. I found a handy script that I then adapted from PHP. It basically sets the left and right values based on parent ids. So you need a table where each entry has an 'id' and a 'pid' as well as 'lft' and 'rgt'. I find it easy to map the ids to their re...

Possible Memory Leak in CFReadStreamRead??

Hi Stackoverflow, I know this might be not correct at all, but I'm currently getting memory leaks in Instruments while using CFReadStreamRead and CFReadStreamOpen. The code looks like this: UInt8* streambuffer = malloc(kReadStreamBufferSize); int readBytes = CFReadStreamRead(httpReadStream,streambuffer,kReadStreamBufferSize); ... free...

XCode has poor syntax checking for Objective-C properties?

I unintentionally compiled the following statement: manager.groupName - lastGroupName; Instead of: manager.groupName = lastGroupName; I am trying to understand why the compiler does not even provide a warning for the former statement I unintentionally provided. The statement has no effect, even it if is legal to subtract pointers ...

How do I query Core Data to return the nearest XX objects to me?

I have populated a Core Data database and need to query it based upon my users location. We use similar code at the backend of a webservice as a UDF and return the distance as a column, but we now have a requirement to cache some of this data for offline use. I know CLLocation has a distanceTo method but is this going to be efficient wh...

Is this undefined behaviour with Objective-C properties?

I had something like the following code in a project I recently worked on. @interface DetailsViewController : UIViewContoller { UIView* headerView_; } @property (nonatomic, retain) UIView* headerView; @end @implementation DetailsViewController @synthesize headerView = undefinedVariableName_; // ... @end undefinedVariableName_ was n...

iPhone/iPad application storage

Hello all, So as a learning exercise, I am trying to make a simple file browser that interfaces with a file storage mechanism. (Think dropbox or box.net) I want to add a feature that would allow the user to flag a file for local storage so they could view it when they were not connected to the network. Is there an apple API that allo...

One UIViewController with many UIViews

Hi there, I'm creating an app with one UIViewController and many UIViews. I have MainViewController with a UIView underneath it that displays when loaded up and a few other UIViews all in the MainWindow.xib. How do I go about switching from one View to the next? Update: Thanks for the reply. I have added MainViewController to my app...

how to find which objects are selected:TRUE from 64 buttons labelled b1, b2 etc...

Hi, I have a project where there are 64 buttons, you have to click certain ones, then click 'done'. If you clicked the right ones, you get some points, and those then need to disappear. I have let the user keep track of which buttons are pressed by doing sender setSelected:TRUE. The first bit is all working fine, but I'd like to be abl...

Refresh iPhone For progressbar

How would i show that the progress bar is working there is no Refresh() in objective-c like there is in .net what would i use for example contactprogress.progress = 0.5; StatusLabel.text = @"Status: Address Found"; How would i refresh the view to show that the progress has changed & show user the StatusLabel status? Thanks Mas...

calling function in objective-c ?

Hello all, let's say in a project there are 1.h, 1.m, 2.h and 2.m if i have a function inside 2.m how can call it from 1.m Thanks Bob ...

Good Cocos2d iphone tutorials?

I've been trying to learn Cocos2d iPhone, and I've been looking for tutorials. Does anyone know of any good tutorials that are modern and towards beginning? I've been doing Objective-C for about 6 months, so not that beginning. Thanks ...

encodeWithCoder Not getting called

I have an object (testSession) that complies to NSCoder and when I use: [NSKeyedArchiver archiveRootObject:testSession toFile:filename]; It has: @interface Session : NSObject <NSCoding> { and has encodeWithCoder: and initWithCoder: functions. Neither are getting called. What would prevent this? - (void)encodeWithCoder:(NSCoder *)e...

One xib file or multiple xib files

I made a tab bar application that has only one xib file. If you have have made tab bar applications before then you probably know what I did so I don't really have to explain it. I deleted the two xib files and used MainWindow.xib. I just added views to each tab bar button and assigned view controllers to each of them. So now I have a t...

Different between self.myIvar and myIvar?

What's the difference between referring to an instance variable in an objective-c class as this: self.myIvar and myIvar if it's been declared as a property in the header and synthesized? ...

How much sense does this block make, in Objective-C?

From the docs: int (^Multiply)(int, int) = ^(int num1, int num2) { return num1 * num2; }; int result = Multiply(7, 4); // result is 28 It only looks complicated - the same thing could be done with an function, or not? What's the real point here in this example? ...

How do I copy file data to NSMutable Dictionary on objective C. ????

i m struggling to get this thing done. I read the file and i have to put every record of file in nsmutable dictionary . Anyone having any idea??? ...

Playing one mp3 file (in loop) in OS X 10.5 or higher

How to play an mp3 file, on repeat, on OS X 10.5 or higher? Please reply with a code snippet. Thanks. ...

Navigation-based app + tab bar

I made a tab bar application with several tab bar buttons. Each button is linked to a separate xib file. This works for a xib with a UIViewController and a xib with a UITableViewController. However, it does not work for a xib with a UINavigationController. On the left you can see what it looks like in Interface Builder, and on the right...

Should I autorelease after failure in non-designated initalizer?

Say I have the following class: @interface Frob : NSObject { NSData *data; } - (id)initWithData:(NSData *)inData; @end @implementation Frob - (id)initWithData:(NSData *)inData { if ((self = [super init])) { data = [inData retain]; } return self; } - (void)dealloc { [data release]; [super dealloc]; } @end ...