Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under objectivec...

Shayne says...

I just created a TTPickerTextFieldDemo project, demonstrating the use of a TTPickerTextField outside the TTMessageController (from the Three20 iPhone SDK framework).

I decided to create the demo project after painfully trying to implement it off the cuff in a recent project I’m working on. I ended up taking a step back and creating this demo project by looking over the example implementation in the TTCatalog project along with the TTMessageController source in the Three20 framework.

Checkout the source over at GitHub and if feel free to fork and contribute to the project. I hope this helps someone.

Filed under: objective-c

jimthedim says...

If you put dealloc at the top next to the synthesizes for the class
then you are more likely to add in the required releases in the
dealloc.


Links to iPhone Apps:

http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=333177401&mt=8

Filed under: objective c

what2day says...

Because what I really need to do is learn yet another programing language I'm taking an iPhone Development class at machine project with Chandler McWilliams as the instructor.

He recommended the book Cocoa Programming for Mac OS X and since fellow-student Matthew Iadarola got it out of the library we decided to give the first example a shot: the random number generator.

It had to be adapted some for the iPhone since this is not an iPhone book, but we got it done.

I posted the code for M.I., heavily commented, here. I also uploaded the Buttons example from class b/c I reference it in my comments. 

There are two versions, functionally virtually identical, but the UI layout in one is much more streamlined. It's all about design.

images: v2, v1, icons

     
Click here to download:
Hello_Random_Number_on_the_iPh.zip (454 KB)

Filed under: Objective C

chak says...

The latest release of Mac OS X (Snow Leopard) came with an upgrade to the C and Objective-C languages, adding lambda abstractions — which they call blocks. Matt Gallagher has a nice blog post that describes some of the trickier aspects of blocks: http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html

Interesting is the function 'newDoubleToIntComparison' (in Section "Declaring a block that returns a block"), which is a curried[1] version of 'compareDoubleToInt'. Together with the explicit memory management for returned blocks and the need for involved type annotations and casts, it becomes clear why functional languages like Haskell make curried functions the default as well as support garbage collection and type inference out of the box.

[1] http://en.wikipedia.org/wiki/Currying

Filed under: objective-c

Originally posted at http://www.richardhyland.com/diary/2009/10/17/how-to-embed-a-map-on-the-iphone/ (Posterous keeps messing with the code layout, go the original post on my website for the working version!)

 

In the first of a few posts I intend to make I’ll demonstrate some examples using the iPhone SDK.

This example will demonstrate how to embed a map, using the MKMapKit framework inside a UIView using the iPhone SDK. Note you must be using iPhone OS 3.0 or higher for this to work. The ultimate aim is to get a UIView that looks similar to this.

For this example I will assume you are already familiar with navigation and UIViews in the SDK (and so I won’t cover how to get the navigation bar at the top of this screenshot)

MKMapKit

Add the framework

First up you must go to the Frameworks folder of your XCode project and add the existing framework of MKMapKit.

Then inside the header file for your view add

  1. #import <MapKit/MapKit.h>  

Adding MapKit references to the header

Now we must add the mapKit instance to the header as well as the MapKit delegate

  1. @interface MapKitViewController : UIViewController <mkmapviewdelegate> {  
  2.     MKMapView *mapView;  
  3. }  
  4. -(void)displayMap;  
  5. </mkmapviewdelegate>  

Initialize the Map

  1. - (void)viewDidLoad {  
  2.     mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];  
  3.     mapView.delegate=self;  
  4.   
  5.     [self.view addSubview:mapView];  
  6.     [NSThread detachNewThreadSelector:@selector(displayMap) toTarget:self withObject:nil];  
  7. }  
  8.   
  9. -(void)displayMap {  
  10.     MKCoordinateRegion region;  
  11.     MKCoordinateSpan span;  
  12.     span.latitudeDelta=0.2;  
  13.     span.longitudeDelta=0.2;  
  14.   
  15.     CLLocationCoordinate2D location;  
  16.     location.latitude = -35;  
  17.     location.longitude = 146.2381;  
  18.     region.span=span;  
  19.     region.center=location;  
  20.   
  21.     [mapView setRegion:region animated:TRUE];  
  22.     [mapView regionThatFits:region];  
  23. }  
  24.   
  25. - (void)dealloc {  
  26.     [mapView release];  
  27.         [super dealloc];  
  28. }  

This will give us a map fitting the screen with the region and zoom level set to best fit the coordinates given. Note that I have physically defined the coordinates here in this example, you can use something like the Google GeoCode API to convert addresses, etc to coordinates. I won’t cover that here.

Changing the map type

In the example above is a tool bar allowing you to switch map types

Let’s define the toolbar in the header file inside the @implementation

  1. UISegmentedControl *buttonBarSegmentedControl;  

Now inside the main code inside ViewDidLoad we add

  1. buttonBarSegmentedControl = [[UISegmentedControl alloc] initWithItems:  
  2.     [NSArray arrayWithObjects:@"Standard", @"Satellite", @"Hybrid", nil]];  
  3.     [buttonBarSegmentedControl setFrame:CGRectMake(30, 10, 280-30, 30)];  
  4.         buttonBarSegmentedControl.selectedSegmentIndex = 0.0;   // start by showing the normal picker  
  5.     [buttonBarSegmentedControl addTarget:self action:@selector(toggleToolBarChange:) forControlEvents:UIControlEventValueChanged];  
  6.     buttonBarSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;  
  7.     buttonBarSegmentedControl.backgroundColor = [UIColor clearColor];  
  8.     [buttonBarSegmentedControl setAlpha:0.8];  
  9.   
  10.     [self.view addSubview:buttonBarSegmentedControl];  

Then we must add the function for what happens when we tap on the tool bar

  1. - (void)toggleToolBarChange:(id)sender  
  2. {  
  3.     UISegmentedControl *segControl = sender;  
  4.   
  5.     switch (segControl.selectedSegmentIndex)  
  6.     {  
  7.         case 0: // Map  
  8.         {  
  9.             [mapView setMapType:MKMapTypeStandard];  
  10.             break;  
  11.         }  
  12.         case 1: // Satellite  
  13.         {  
  14.             [mapView setMapType:MKMapTypeSatellite];  
  15.             break;  
  16.         }  
  17.         case 2: // Hybrid  
  18.         {  
  19.             [mapView setMapType:MKMapTypeHybrid];  
  20.             break;  
  21.         }  
  22.     }  
  23. }  

In the next example, coming soon, I’ll cover how to add the annotations (the small pins) to the map

 

Filed under: objective c

Cappucino (http://objective-j.org/)
Cappuccino is an open source application framework for developing applications that look and feel like the desktop software users are familiar with.

Cappuccino is built on top of standard web technologies like JavaScript, and it implements most of the familiar APIs from GNUstep and Apple's Cocoa frameworks. When you program in Cappuccino, you don't need to concern yourself with the complexities of traditional web technologies like HTML, CSS, or even the DOM. The unpleasantries of building complex cross browser applications are abstracted away for you.

Cappuccino was implemented using a new programming language called Objective-J, which is modelled after Objective-C and built entirely on top of JavaScript. Programs written in Objective-J are interpreted in the client, so no compilation or plugins are required. Objective-J is released alongside Cappuccino in this project and under the LGPL.

280Slides: Presentation Application build using Cappucino
http://280slides.com/

280Atlas: Applicatiopn Designer for Cappucino-based apps


http://280atlas.com/
http://carsonified.com/blog/web-apps/introducing-atlas-a-visual-development-tool-for-creating-web-apps/

280North: Company behind Cappuccino, Atlas, 280Slides
http://280north.com/

Filed under: objective-c

John says...

There are some great books out there to help you learn the iPhone SDK, Objective-C and Cocoa.  Here's a link to a few of the best: Link

Filed under: objective-c

jimthedim says...

I have been coding since I was 14 (31 years) and in those years I am
sure I once learnt that you should think before just coding something.
 
Well I seem to have forgotten that. Over the last couple of days I
have been trying to put the finishing touches to the application. But
have hit a major snag.
 
Things that appeared to be such a good idea at the time (i.e. they
made my life easy at that point in time) have come back to bite me in
the location that people get bit in.
 
I have been re-factoring the code to allow me easier coding overall
and now nothing works. It all compiles but when it runs it no longer
works.
 
Objective C is one of those languages where the messages an object can
respond to can change at runtime and so the compiler cannot always
check that the code is correct.
 
So I now have to go through all the code from scratch and figure out
what tiny piece I have broken.
 
Oh well, I think this is one of those lessons that have to be
periodically re-learnt.

Filed under: objective c

jimthedim says...

I have been dabbling in iPhone programming for months now. Since
programming is my day job it can be quite hard to motivate myself but
recently progress has been made.
 
I am not far off my first iPhone app being finished. It has been a
steep learning curve. I have never used Objective C, nor used XCode
or the Interface Builder before so it was hard.
 
My first application is simple and is really just a tester to
determine whether I wanted to carry on with programming on the iPhone.
 I have an iPod touch and I will be loading it onto that soon and
making sure it works properly.
 
There will be more news on what the App is in my next post.

Filed under: objective c

elvezpablo says...

While I do like Interface Builder the more I use it I need some way of generating views for SuperTwitter via a factory so I'm working with the base no view project in XCode and used this tutorial to get started. I have to say I'm becoming a fan of the IB-less project. More on that later.

Filed under: Objective C