objective-c

NSCalendar: Problem getting weeks in a month...

I am creating a calendar control of sorts... One thing I need to know is how many weeks are there in a Month... So NSCalendar rangeOfUnit:inUnit:forDate Seems to be exactly what I need... Except I am noticing something that seems off and I can't quite figure out why this is happening... The following code... NSCalendar *calendar = [...

Using undecorated UiNavigationBar

Hello, I would like to use UINavigationBar without decoration. I.e. I would like to create my own custom buttons and link those to the same actions (e.g. back) as the navigation items were linked to and have no bar presented at the top. I was told that one should use navigation bar even though graphically you should design the interacti...

How to put an image and a bottom text together in a UIButton?

Hello, guys. I want to put an centered image and a bottom centered text in a UIButton. How I can do that? Thanks in advance. ...

For UITableViewCell (on iPhone) I need to figure out how to get it's current position?

So, idea is the following. I have UITableViewCell, and when I click on it, I want to show UIActivityIndicatorView right in this cell. I cannot figure out how do I find the X/Y or any position (I can find the frame size of UITableViewCell though but it does not help much :-) for the given cell. Any tips? Help? Thank you! ...

sqlite3 datetime not functioning properly on iPhone

Hello, I am having trouble getting sqlite3 to do comparisons between datetimes. On my mac, when I run the sql queries, it works. However, on the iPhone, the exact same query fails. I have a sqlite3 table setup as follows: CREATE TABLE IF NOT EXISTS `Artists` ( `id` int(11) NOT NULL PRIMARY KEY, `name` varchar(256) NOT NULL, `lastUp...

Objective-C @class / import best practice

I've noticed that a lot of Objective-C examples will forward declare classes with @class, then actually import the class in the .m file with an import. I understand that this is considered a best practice, as explained in answers to question: http://stackoverflow.com/questions/322597/objective-c-class-vs-import Coming from C++ this fee...

iPhone SDK - Load nib offscreen and save as image to Camera Roll

So I have a nib I've created that's basically just a view that's larger than the iPhone screen size. Within it is a UIImageView, set up as outlet "framedImage". In my code, I want to initialize the nib offscreen, set framedImage's image property to a UIImage object I already have created in the code (called "myProcessedImage"), then save...

Distinct Value Array for View Controller Index Using Core Data

Hi, I'm trying to create an index representing the first letter value of each record in a Core Data store to be used in a table view controller. I'm using a snippet of the code from Apple's documentation. I would simply like to produce an array or dictionary of distinct values as the result. My store already has the character defined wi...

keyDown works but i get beeps

I just got my keydown method to work. But i get system beep everytime i press key. i have no idea whats wrong. Googled for hours and all people say is that if you have your keyDown method you should also implement the acceptsFirstResponder. did that to and it still doesn't work. #import <Cocoa/Cocoa.h> #import "PaddleView.h" #import "Ba...

Recording custom overlay on iPhone

Hi all, I'm interested in recording a video with a custom overlay which would end up in the video itself. They could be UIImage or even better, an OpenGL viewport, is there even such possibility right now on any iPhone devices/SDK ? Thanks ...

Extracting a URL from within a string

My app receives numerous text strings which may or may not contain a URL anywhere within the string. What would be the best method to extract a URL from within a string? Thank you. ...

Figuring if a link is clicked on a webView - iPhone

Hi, I am using a custom webview to show a tabbar when user touches on the webview. But when I clicked on a link in a webview, tabbar is shown for a little time and then page loads. I am using this custom webview to detect touch: http://github.com/psychs/iphone-samples/blob/b772b963f2acf18d478b41b44555992fcd8d4f31/WebViewTappingHack/Clas...

When to retain a "delegate"

I know that in Objective-C you should never retain your delegates because it may cause a retain-cycle, however, how do you know the difference between a delegate and a non-delegate object ? Can't it be said that just sending a message to any object is delegating work to that object ? ...

How Does Appcelerator Titanium Mobile Work?

I'm working on building an iPhone app with Titanium Mobile 1.0 and I see that it compiles down to a native iPhone binary. How does this work? Seems like it would take a lot of heavy lifting to analyze the JavaScript code and do a direct translation into Objective-C without having a superset language like 280 North's Objective-J and Cap...

How to find why NSMutableData is invalid

I access a RESTFUL url and get back results. The results are in JSON. I turn the response into a string via: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *json = [[NSString alloc] initWithBytes:[self.receivedData mutableBytes] length:[self.receivedData length] encoding:NSUTF8StringEncoding]; The json...

Is it possible to use PVRTVC textures in UIImages?

I'm running into some issues with having a lot of UIImages in memory, so I was wondering if there is any way of using PVRTC images instead of PNGs in UIImages. ...

Create a UIView Subclass that calls a delegate function whenever it's parent viewController appears?

EDIT 2: I now think the best soluton is to create ListeningView.h that just includes a ListeningView protocol, instead of subclassing ListeningView (since we can't do multiple inheritance in Obj-C). Then, you still need ListeningViewController as well. EDIT: Ok, I figured out what the approved idiom is here. I should subclass UIViewCont...

Memory leak found with clang but cant release and autorelease crashes

I have a class that builds a request based on a few passed in variables. The class also has all the delegate methods to receive the data and stores it in a property for the calling class to retrieve. When the class initializes it creates a connection and then returns itself: NSURLConnection *connection; if (self = [super init]) { ...

NSTextField and hidden property

Hi, I have an NSTextField that I hide when the user presses a button. I hide the text field using [textField setHidden:YES]; The problem is that is the user is typing in the text field (i.e. the text field is first responder) and the user presses the return key (which is the key equivalent for the button that hides the text field) the u...

Zooming in an NSView

Hi, I have an NSView in which the user can draw circles. These circles are stored as an array of NSBezierPaths, and in drawRect:, I loop through the array and call -stroke on each of the paths. How do I add a button to zoom in and out the NSView? Just change the bounds of the view? Thanks. ...