objective-c

Using three20 to display a table view with styled text

I'm trying to get my head around three20. It's a big beast, but I want it to do just a small thing - display a table view with styled text within the cells. How would I create and show such a table? ...

Properly handling NSURLConnection errors

Hi, I have a simple form interface set up that send username and password information to a server: (working) NSString *postData = [NSString stringWithFormat:@"user=%@&pass=%@",[self urlEncodeValue:sysUsername],[self urlEncodeValue:password]]; NSLog(@"Post data -> %@", postData); /// NSData* postVariables = [postData dataUsingEncodin...

objective c- property

Hello all , I think i am missing somthing with property attributes. first i cant understand the different between retain and assign? If i use assign does the property increase the retain counter by 1 to the setter and also to the getter, and i need to use release to both of them? and how this work with readwrite or copy? from the view ...

How to open a link in Safari with three20?

With the three20 library you can create styled text, including links, but how do you get those links to open in Safari (or within the app itself)? ...

Objective-C: Initializing char with char at index of string.

unichar myChar = [myString characterAtIndex:0]; [myNSMutableArray addObject:myChar]; I am trying to insert the first char of a string into an array, to create an array of chars. the first line does not give me an error. The second line however, provides the following error: warning: passing argument 1 of 'addObject:' makes pointer from...

double checked locking - objective c

I realised double checked locking is flawed in java due to the memory model, but that is usually associated with the singleton pattern and optimizing the creation of the singleton. What about under this case in objective-c: I have a boolean flag to determine if my application is streaming data or not. I have 3 methods, startStreaming, ...

Insert a tag with NSFileHandle

Hi, I want insert a tag in the Xml file. I have NSFileHandle object and i know the "offsetInFile" and the "seekToFileOffset:" methods but i don't know how to use. I have the Xml below and i want insert a tag between "positions" and "/positions" tag. Thanks so much. <?xml version=1.0 encoding=UTF-8 ?> <positions> //I want insert in thi...

Assigning a selector via SEL type?

I just spotted the following in an online tutorial. It showed 001 as a method for assigning a selector, however I could not get this to work. Am I right in thinking that 001 is not right and 002 is the correct way, or am I doing something wrong with 001? // 001 SEL mySel = [self something]; // 002 SEL mySel = @selector(something); ...

Pre loaded database on iPhone?

Hi, I have recently developed an app using core data as the storage db. The app allowed the user to read and write to the db. I am now developing a new app which the user doesnt need to write anything to the db, instead the app just needs to read the data. The data has relationships etc so cannot just use a plist or something similar. M...

Mac OS X Status Bar Application - Hiding it from Cmd/Alt menu?

I'm trying to whip up a simple little Status Bar Application in Obj-C/Cocoa. So I have done it pragmatically - declaring an NSStatusItem, adding it to the NSStatusBar and then giving it a NSMenu object. A bit like this... NSStatusBar *bar = [NSStatusBar systemStatusBar]; theItem = [bar statusItemWithLength:NSVariableStatusItemLength]...

Best way to use custom TTButton with interface builder

Hi, I am quite new to the whole IPhone development thing and was playing around with the Three20 library. The samples for this library showed me an easy way to create a nice looking button with styles etc and this to my view: TTButton* button = [TTButton buttonWithStyle:@"forwardActionButton:" title:@"Login"]; [button setFrame:CGRectMa...

className method?

I have just been watching the Stanford iPhone lecture online from Jan 2010 and I noticed that the guy from Apple keeps referring to getting an objects class name using "className" e.g. NSArray *myArray = [NSArray arrayWithObjects:@"ONE", @"TWO", nil]; NSLog(@"I am an %@ and have %d items", [myArray className], [myArray count]); Howeve...

Real world goods in iPhone app?

I've seen questions asked here before, but they do not address the issue. That said: "In App Purchases" specifically may not be real world goods or services, according to Apple's guidelines. What services allow integration with iPhone apps so that I can use ObjectiveC to sell things in an iPhone app? In other words, how can I sell st...

All UITableCells rendered at once... why?

I'm extremely confused by the proper behavior of UITableView cell rendering. Here's the situation: I have a list of 250 items that are loading into a table view, each with an image. To optimize the image download, I followed along with Apple's LazyTableImages sample code... pretty much following it exactly. Really good system... for ref...

UISlider value to string

i am getting error: cannot convert to pointer type NSMutableDictonary *mydictonary; [mydictionary setValue: [mySlider.value UTF8String] forKey: @"BR"]; ...

UIView as dictionary key?

I want to have a NSDictionary that maps from UIViews to something else. However, since UIViews do not implement the NSCopying protocol, I can't use them directly as dictionary keys. ...

How can I shuffle an NSArray?

All examples I find on shuffling arrays are for NSMutableArrays. Copying an NSArray to an NSMutable array, shuffling, then copying back always crashes the application. Is it even possible to shuffle an NSArray? Anything in objective-c similar to Collections.shuffle() (Java)? Edit static NSUInteger random_below(NSUInteger n) { NSUInteg...

Why isn't my ScrollView/CATiledView zooming properly?

I have a UIScrollView backed by a CATiledLayer. The layer is pulling tiles from a server and displaying them in response to what is requested when drawLayer:inContext is called. Here's what it looks like: -(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{ ASIHTTPRequest *mapRequest; WMSServer *root = self.mapLayer.pa...

Memory Leak when using SDURLCache (subclass of NSURLCache)

I am using Olivier Poitrey's SDURLCache (github link) as an alternative to NSURLCache to enable disk-caching in an iPhone app. It works very well but is curiously leaking a NSHTTPURLResponseInternal when a disk cached object is returned (no leak when object is returned from memory or no object found). The following code snippet shows ho...

Losing NSManaged Objects in my Application

I've been doing quite a bit of work on a fun little iPhone app. At one point, I get a bunch of player objects from my Persistant store, and then display them on the screen. I also have the options of adding new player objects (their just custom UIButtons) and removing selected players. However, I believe I'm running into some memory ma...