RemObjects Software Gears
 
       

WWDC09 Roundup

{#} by marc hoffman 06/13/09 06:42:32 pm, 616 words, Categories: RemObjects, non-tech, ROFX, Cocoa, Mac, iPhone

So, WWDC09, Apple's World Wide Developer Conference, is over, and i'm sitting in my room at the excellent Hotel Monaco getting ready to leave San Francisco.

For every conference i go to, i plan to blog more extensively about it, but of course that never happens, because there's just too much good stuff going on throughout the week to find the time to sit down and write about it; WWDC has been no different.

I know most people following WWDC from afar only see the keynote on monday, but of course that is only the start of a full week of info straight from the firehose, and – while fun &ndash pales in comparisson to the real meat of the conference.

This year, there has been lots of exciting news from the developer tools front. Xcode, the development IDE for both Mac and iPhone, is getting vastly expanded, with things such as deep integration of the Clang Static Analyzer (which admittedly i had been playing with for a month now, so it was not brand new for me, this week) and a new and vastly better Clang-LLVM based compiler to replace GCC (which still is the default, though). And that's just the tip of the eisberg. And the rest of the tool suite, such as Instruments, is seeing significant improvements as well.

Due to the work i do at RemObjects, i always find myself in some sort of a "meta-developer" position at conferences like these. While most attendees see, say, new improvements in Instruments and think "that's great, how can that help me write apps?", i think "great, how can we leverage this to help our customers write their apps?".

And i think there's great potential here for deeper integration of RemObjects SDK and Data Abstract with tools such as Instruments, to make your life easier (and the same goes for GCD).

In addition to the tool chain, there's also lots of good stuff happening in the OS and libraries, to benefit developers. Of course this is all largely under NDA, so i cannot say too much, but just take Grand Central Dispatch, for instance.

While GCD was already announced (not in the public keynote, but to developers) at last year's WWDC, this week went into much more detail, and it's amazing to see just at what level of both the OS and its applications, but also the developer APIs, GCD is being employed. Having a great technology as GCD made available is one thing (and the Parallel Framework on .NET offers something comparable), but seeing how virtually every of the OS's APIs has been revised to make use of it, and seeing – first hand – the sort of performance improvements Apple has been able to get out of the technology by consistently applying it to all of their code as well, is mind blowing.

With this, and the great enhancements to the entire tool chain, i feel once again ensured that this is a great platform (or actually, two great platforms) to invest in.

And to think the entire tool chain, from Xcode to all the professional tools it comes with, comes free with the system (remember that, the text time someone wields the Apple Tax myth).

In any case, i should start to pack and catch my flight. It's been a great week of learning and meeting great people, and i, for one, already can't wait for WWDC 2010...

yours
marc hoffman
Chief Architect

ps: a couple of great food recommendations in San Francisco:

  • OSHA Thai Restaurant on 2nd, between Howard and Mission. Awesome food.
  • John's Grill on Ellis, between Stockton and Powell. Home of the Maltese Falcon and great steaks and seafood

RemObjects "Summer 2009" Releases Available, and More...

{#} by marc hoffman 05/30/09 02:02:49 pm, 517 words, Categories: main, RemObjects, .NET, ROFX, Delphi, Cocoa, Mac, Windows

Yesterday has been the culmination of one of the busiest months here at RemObjects.

To start with, we've shipped a new round of updates for all of our products, most noticeably a major new version 6.0 of Data Abstract and RemObjects SDK for both Delphi and .NET. Even though the products have been on a subscription model for a while now, and the new release is free to all active subscribers like every other 5.0.x update in the past, we felt the version bump was justified given the wide range of new features we've shipped (and are planning to ship over the rest of the year).

Most dear to my heart among these is our support for ZeroConf service discovery, which imho will be a game changer for how easily RO (and DA) servers and respective clients can be deployed, and the new suite of sample applications in DA/.NET (which we'll expand/port to DA/Delphi for August). The new samples will make it much easier and more intuitive for people to get started with DA and explore all that is there, without any problems hving to set up test databases or the like.

Along with the new product releases, we've also launched a major rework of the website, with Data Abstract how having its own dedicated product home page at dataabstract.com, just as RemObjects SDK got, earlier this year (rosdk.com). A lot of work has gone into this and i hope you like how the product is presented.

Finally, we also made some changes to the remobjects.com homepage; most importantly, we've phased out our old news feed (which we found was getting stale too quickly) and now show messages from our newly created @RemObjects twitter feed, instead. Several members of the RemObjects team have been actively twittering for a while now, about both personal and business-related matters (find em all here), but we decided we needed a more official feed focused solely on RemObjects-related matters. So, to stay up to date you can now simply follow us or subscribe to the RSS.

On a somewhat unrelated note, some of you have asked about the lack of new releases for the "for OS X" line of products, yesterday. For logistical reasons (it's a lot of work getting all of these builds organized and out the door, for one thing, and our Mac products require a different build environment that the rest – which are all handled by our Windows-based build server &ndash for another) we are keeping these on a separate build schedule for now. We shipped the first release of RO/OSX in early April, and made new beta builds of both RO/OSX and the unreleased DA/OSX available earlier this month. We are planning on having our second release of RO/OSX out in late June/early July. If all goes well, the build cycles will converge with the Windows-based products eventually – more on that later.

That much for now – thanx for reading and i hope you will enjoy the new products and website.

yours,
marc

Now on the App Store...

{#} by marc hoffman 05/29/09 12:37:16 pm, 75 words, Categories: RemObjects, ROFX, iPhone

A bit ahead of the regular new product releases coming out later today, i'm happy to let you know that our second iPhone application has become available on the App Store, at midnight, tonight!

Very much a companion to the upcoming RemObjects SDK releases, ROZeroConf Browser (appstore link) is a free application that allows you to browse for available ZeroConf/Bonjour servers on the network your iPhone (or iPod touch) is connected to.

Enjoy,
marc

Photo of the Week #26

{#} by marc hoffman 05/21/09 03:46:21 pm, 41 words, Categories: Cocoa, Mac, Photography




“It's Raining Again” — see it on dwarfland.com

HDR from 11 exposures shot with the D300. That's Xcode running on the MacBook; lying next to it is my old (now IR-converted) D50 with the Sigma 300mm attached. Shot today.

See Delphi Prism in Visual Studio 2010 Beta 1

{#} by marc hoffman 05/19/09 04:33:30 pm, 108 words, Categories: RemObjects, Oxygene, .NET, Visual Studio

Visual Studio 2010 Beta 1 is available on the MSDN Subscriber's Downloads Page since last night, finally putting the new version of Visual Studio out to the general public.

Below, you'll find a screenshot of the latest internal build of Delphi Prism running in Visual Studio 2010 on Windows 7 RC1. Note the new WPF based code editor (which will allows us to do many cool things, in the long run) in the background, and the new New Project dialog listing available Prism templates.

We're working on getting this VS2010 support out to field testers soon, and to officially support Visual Studio 2010 in the August release of Delphi Prism and RAD Studio.

Introducing “RemObjects Builder”

{#} by marc hoffman 05/11/09 10:48:43 am, 470 words, Categories: RemObjects, ROFX, Cocoa, Mac

This month is probably the busiest we've had in a long time. Last week, we RTMed a new release of Delphi Prism with many major new features, and also shipped the first beta of Data Abstract for OS X to our testers and pre-order customers. And we're preparing for what probably will be the most major update to our Data Abstract and RemObjects SDK suite of products for Delphi and .NET in the last year or two, later this month.

So what better time is there to start a new project, right?

What happened was that last week i was sitting at my MacBook and preparing the beta drop for DA/OSX, continuously running my bash-based build script in terminal, finding the next build error (this was the first time i was automating the DA build and getting it all put together) and realizing i really missed FinalBuilder, the excellent tool we use to run the automated builds for our windows products. I shot a few messages out via twitter, and it seems that everyone else did, too!

I figured, a tool was needed to run builds in a more visual way, to allow me to better see what was happening, what was currently building, and at which step things went south if they did. Xcode's (and by extensions, GCC's) command line build output is way to verbose to follow along with it in terminal.

So i put a couple hours aside and started "RemObjects Builder", the tool you see below, which is basically a runner for bash based scripts that lets you see progress and results nicely.

Mind you, the idea here was not to create a full-blown FinalBuilder clone – that's far too much work, not to mention overkill at least for what i need. I'm perfectly fine with writing and editing build scripts in a text editor (and Builder runs plain shell script files, so the same file can be run win Builder, or in Terminal), i'm mainly interested in the more visual run process.

But who knows what the project takes off to…

I've decided to turn this into an open source project hosted at code.remobjects.com, in order to give back to the community, and also to get some more people involved in the project.

For now, the project is still marked as private; there's still some (many) rough edges, and i don't want any potential users or contributors turned off by those, but if you're interested in participating in the project, just sign up on code.remobjects.com and send me your username – i'll activate the project for you. Hopefully, in a couple weeks we can turn it public so it is accessible by everybody.

Let me know what you think!

 

ps: no, do not ask what TwinPeaks.framework is ;)

Delphi Prism — May 2009 Release Has RTMed

{#} by marc hoffman 05/07/09 05:32:44 pm, 75 words, Categories: RemObjects, Oxygene, .NET, Visual Studio, Delphi

I hope you'll be pleased to hear that the final RTM build for the Delphi Prism May 2009 release has just been completed, and is on its way thru the troublesome and adventure-ridden path to customers, where hopefully it shall arrive some time next week.

Enjoy,
marc

Life on Mars — Photo(s) of the Week #25

{#} by marc hoffman 05/02/09 05:38:41 pm, 91 words, Categories: non-tech, Photography

Ever since i got my D300 last December, my old Nikon D50 has been burning a hole in my pocket, as they say. A couple weeks back, i finally decided to send it off to be converted to a pure infrared camera. Today it came back, so i took it on a trip thru some of my favorite parks in Berlin. Some 15km and 250+ photos later, here are some initial highlights (with light post-processing in Lightroom 2 only):


11963


11963


11963

From the “Life on Mars” set — see more on dwarfland.com

Coming in May: New Suite of Samples for Data Abstract

{#} by marc hoffman 11:04:00 am, 605 words, Categories: RemObjects, .NET, Visual Studio, ROFX, Delphi, Cocoa

As mentioned in my previous post, we have a new suite of samples coming in the may releases of Data Abstract.

It all started back when we were preparing for exhibiting at PDC2008. We took a good look at the exiting samples we had, and decided it would be a good time to start afresh and make them more consistent.

One important factor was that at the time, all samples were unique client/server combinations, talked to different databases and did not have much in common in general. To best be able to show and present DA, we decided to develop one unified sample server application (along with a standard database) that all clients would talk to. This way, we could have one server running, and just launch different clients (either as executable or as projects to show within Visual Studio) to show off specific functionality.

To make things more interesting, we also decided to not make the server app a black box, but instead provide a very rich user interface that would show exactly, what was going on in the server to process requests - say, to illustrate how DA SQL was being translated to SQL that would be run against the back-end server, now Dynamic Where clauses would be interpreted, or what work would go on to merge data for a schema-side Union table.

This was a great success, so we decided to turn this into what we would ship as as samples with the product, eventually - and while we did not have the time to get everything ready for the Spring 2009 releases in February, the time has come and at the end of this month, we'll ship the new sample suite for Data Abstract for .NET.

After installing the next release of DA, you will find (among other new things!) two new shortcuts in the start menu, to launch pre-compiled versions of this sample server. The server comes ready to run with a SQLite-based database that will work out of the box, so there is absolutely no setup work needed, anymore, to get started. As always, a range of sample applications are available from the Welcome page in the IDE - these are now all client-only samples that will work out of the box (open, build, run) against the provided server, making it really easy to start exploring.

We of course ship full C# source of the sample servers (we have two versions, one based on WPF with the very rich user interface mentioned above, as well as a lower-key version based on WinForms, for users who are still using .NET 2.0-only) so you can explore, change and rebuild the server.

This all is shipping for .NET edition for Data Abstract, this month, but we're also working on doing the same for Delphi. For the Fall 2009 releases in August, we will have a matching (and wire-comptible) Delphi-based server, and have converted out Delphi client samples to use this server - just as on the .NET side.

In true RemObjects fashion, the Delphi and .NET versions will be inter-changeable, so the .NET client samples will work against the Delphi server, and vie versa.

Once we start rolling out Data Abstract for OS X (the first beta of which will actually go out to testers this week), it too will leverage the same sample infrastructure - in fact we'll have a copy of the DA/.NET based server with a Monobjc based front-end that runs Mac side.

We're still in the progress of writing up information about all the samples, but you can get a first glimpse at them on wiki.remobjects.com.

Prism Wiki Now Uses CDN Logins

{#} by marc hoffman 04/27/09 02:15:34 pm, 65 words, Categories: Oxygene, non-tech, Visual Studio, Delphi

This is just to let you know that Prism Wiki has been updated to use standard CodeGear Developer Network logins, so everyone who has a username and password for CDN (and if you ever activated your copy of Delphi Prism, you do) can now log in and contribute to the wiki using that same account, rather then needing a separate remobjects.com login.

Enjoy,
marc

Teaser: PCTrade sample client for DA/OSX

{#} by marc hoffman 04/26/09 07:45:52 pm, 273 words, Categories: RemObjects, ROFX, Cocoa, Mac

One of the new features for Data Abstract we'll be shipping in the May releases is a completely revamped sample infrastructure. I'll be talking more about this in a future post later this week, but basically, we've created one big sample server application, based around a fictional "PC Trade" database that we ship for SQLite, MSSQL and Firebird, that all new client applications talk to.

The idea being that without major setup, you can "just run" the server, and then play around with the client applications.

What i did in the last couple hours (literally) today is create a client application for the iPhone for this. With literally a handful of lines of DA code, "PCTrade for iPhone" can browse available products, client data, and review orders. All data fetching is done asynchronously in the background, making sure the UI always stays responsive.

In a nutshell, the code below does all the magic to – in this example – fetch Products, via DA SQL. The rest of the app is standard Cocoa Touch plumbing.

- (void)viewDidLoad 
{
    //...
    DAAsyncRequest *a = [[rda beginGetDataForSQL:@"SELECT * FROM Products" start:NO];
    [a setDelegate:self];
    [a start];    
}

- (void)remoteDataAdapter:(DARemoteDataAdapter *)adapter 
           didReceiveData:(NSData *)data 
          forAsyncRequest:(DAAsyncRequest *)request
{
    DABin2DataStreamer *bin2 = [DABin2DataStreamer dataStreamerWithData:data];
    [table release];
    table = [[bin2 getDataTable:@"sql"] retain];
    [[self tableView] reloadData];
}

 

We're getting pretty close to releasing a first Data Abstract for OS X beta to pre-order customers and testers, so stay tuned for more information on that, over the next few weeks. Also, as mentioned before, lookout for a more detailed post on the new PCTrade suite of sample apps, later this week.

ARTICLE: Writing a RemObjects SDK for .NET Server and Mac Client - Start to Finish

{#} by marc hoffman 04/21/09 01:21:39 pm, 77 words, Categories: .NET, Visual Studio, ROFX, Cocoa, Mac, Windows

i just finished writing a new walkhru article on creating a RemObjects SDK for .NET server and matching RemObjects SDK for OSX client. Next go giving a complete overview over that, the article also gives a sneak peak at the ZeroConf support that is coming in RO/.NET (and RO/Delphi, as well) this May, which should be of interest to non-OS X developers, as well!

The article can be found on the wiki.

Enjoy; feedback appreciated!

Some RemObjects Software Wallpapers

{#} by marc hoffman 04/19/09 06:51:51 pm, 95 words, Categories: RemObjects, Photography

Below are a couple of new "RemObjects Software" wallpapers i've created over the past few months (all 13" MacBook size, 1280x800, for now - i may provide larger versions depending on demand). Click the images to download full-sized versions.

— These guys were captured last December at the Spree river in Treprower Park, Berlin.

 

— This, believe it or not, is sunlight reflecting off a layer of ice frozen my balcony railing. Shot in early January 2009 at 300mm.

 

— This one, finally, was shot today in Volkspark Friedrichshain using the awesome lensbaby.

 

Enjoy.

Coming in May: Improved IDE support for DA LINQ

{#} by marc hoffman 04/14/09 02:30:27 pm, 353 words, Categories: .NET, ROFX

Another area that will see a big focus in the upcoming Summer releases of Data Abstract is ease of use for DA LINQ.

DA LINQ is an awesome technology, but currently has a bit of a learning curve because the Visual Studio IDE doesn't expose it as well as it could. For 5.0.39, this will change.

One challenge when working with DA LINQ is creating (and updating) the source files that contains the stronly-typed classes that represent your schema. Right now, you need to locate your LinqRmeoteDataAdapter component, right-click and choose "Create DA LINQ Classes", possibly locate your .daSchema file, and pick a destination file. That's a lot of clicks.

In .39, we'll be exposing several IDE features that will make this much easier. One of them that i just finished implementing last night, is a so called "Custom Tool" that can handle generating and updating this code automatically. "Custom Tools" are a generic VS feature that allow source files to generated from other files in the project. One prominent custom tool that comes with Visual Studio is the tool that generates .Designer.pas files for your XSD files, when using traditional DataSet data access model.

DA LINQ now has its own custom tool that can be attached to .daSchema files (simply put "SchemaDALinqGenerator" into the Custom Tool field of the files property inspector), and a corresponding source file will be generated and maintained, automatically:

In the example below, we see the DA Server that drives our website – yes, our entire remobjects.com website is DA LINQ driven – and nested below the ROWebsite4Database-ServerService.daSchema schema file, you can see the .pas file containing all the LINQ classes for this schema:

In addition to the custom tool – which of course depends on the schema being part of the project – there will also be options in the menu and in Solution Explorer to import and update DA LINQ classes from external schemas, for use in client-only solutions that do not include the schema.

These new features will be in the next beta drop of Data Abstract for .NET, and ship in May.

Displaying Variably-Sized Text Cells in a UITableView

{#} by marc hoffman 04/11/09 07:20:32 pm, 1268 words, Categories: Cocoa, Mac, iPhone

For a couple of iPhone apps that i am working on (one is internal, one will hopefully be on the AppStore soon), i needed a flexible way to display text blocks of varying lengths in a list. essentially, i wanted something that looks like this:

This is an ideal candidate for a regular old UITableView, with a custom cell class, and so CaptionAndTextCell was born - a reusable UITableViewCell implementation that is shared by my two apps (and probably many future ones).

So how did i implement this? It’s pretty straight forward. We start by creating a new class descending from UITableViewCell, and call it CaptionAndTextCell. We give it two NSString fields and properties to hold the caption, and text body, respectively:

@interface CaptionAndTextCell : BaseCell 
{
    NSString *caption;
    NSString *text;
}

@property (assign) NSString *caption;
@property (assign) NSString *text;

/* … */

@end;

Besides storing the caption and text, the cell needs to do two core tasks: the obvious one is drawing itself in an overriden -drawRect: method; the second one to actually calculate its size based on the contained text.

Since drawing is difficult without knowing what size to draw at, we’ll start with the second task, and add a new static method to our class, named +cellHeightForCaption:text:width:.

Why a static method? Well, if you’ve looked at the API for UITableView, you will might have noticed that the UITableViewController implementation for your table is responsible for providing the height of individual cells. Because the table view only allocates cells as they need to be displayed, but - for obvious reasons - needs to know the exact height of all cells in advance, we’ll do this calculation in a handy static method hat can be called without actually creating the cell in question. This way, the calculation logic is encapsulated where it should be (inside CaptionAndTextCell), but readily callable. If you ever change how CaptionAndTextCell does its rendering (say, to use a larger font), all your logic is in one place.

All the UITableViewController needs to to to provide the height for a cell is to implement the following method, delegating the actual math to CaptionAndTextCell.

- (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int index = [indexPath indexAtPosition:1];

    NSString *caption = [self getTitleForIndex:index];
    NSString *text = [self getBodyForIndex:index];
    return [CaptionAndTextCell cellHeightForCaption:caption 
                           text:text 
                            width:[[self view] frame].size.width];
    }
}

(i’m assuming your view controller will have some kind of storage for its data, and -getTitleForIndex: and -getBodyForIndex: will provide the necessary strings).

With that out of the way, we can now implement +cellHeightForCaption:text:width:, to do the actual math.

+ (CGFloat)cellHeightForCaption:(NSString *)caption text:(NSString *)text width:(CGFloat)width;
{
    UIFont *captionFont = [UIFont boldSystemFontOfSize:13];
    UIFont *textFont = [UIFont systemFontOfSize:13];
    
    CGSize cs = [caption sizeWithFont:captionFont constrainedToSize:CGSizeMake(width-20.0, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap];
    CGSize ts = [text sizeWithFont:textFont constrainedToSize:CGSizeMake(width-20.0, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap];
    CGSize cs2 = [text sizeWithFont:textFont];
    CGSize ts2 = [text sizeWithFont:textFont];
    if (ts2.width+cs2.width+15.0 < width) return ts2.height+10.0;
    return ts.height+cs.height+15.0;
}

this method does a couple things. first, we grab copies of the two fonts we want to use to render caption and text, respectively. After all, the final size of the text will depend on the font.

Next, we calculate the pixel size of caption and text (cs and ts - i am keeping variable names short because this code already is hard enough to read online, as it stands), if rendered into a rectangle of width-20.0 (leaving 10 pixels of space around our text, on the sides) with standard word-wrapping. These two will determine the final height of our cell.

Note how the width is never hardcoded anywhere. this way, the cell will work fine in landscape mode, as well as on the fabled 10" touch when it comes in June (knock on wood ;).

We also calculate the pixel size of our two texts if rendered on a single line (cs2 and ts2). The idea being that if we find both texts actually fit o the same line, we’ll draw them that way, rather than one below the other.

So depending on whether ts2.width and cs2.width fit on one line (along with some white space) or not, we return the appropriate height.

With that done, let’s look go back to our table view controller, and finish hooking up our new cell class. Any table view controller of course needs to implement - tableView:cellForRowAtIndexPath: to provide data. We just need to make a few changes to the default implementation, to create and return our custom cell class and initialize it:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    int index = [indexPath indexAtPosition:1];
    static NSString *MyIdentifier = @"CaptionAndTextCell";
        
    CaptionAndTextCell *cell = (CaptionAndTextCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) cell = [[[RssItemCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
        
    [cell setCaption: [self getTitleForIndex:index]];
    [cell setText: [self getBodyForIndex:index]];
    return cell;        
}

(once again, you;d replace the calls to -getTitleForIndex: and -getBodyForIndex: with whatever you need to access your data).

We’re almost done; the "only" thing left to do is to tell our cell how to actually draw itself, by overriding -drawRect: as follows:

- (void)drawRect:(CGRect)rect 
{
    UIColor *captionColor = [UIColor blackColor];
    UIColor *textColor = [UIColor darkGrayColor]; 
    UIFont *captionFont = [UIFont boldSystemFontOfSize:13];
    UIFont *textFont = [UIFont systemFontOfSize:13];

    CGRect f = [self bounds];
    
    
    
    CGSize cs = [caption sizeWithFont:captionFont constrainedToSize:CGSizeMake(f.size.width-10, FLT_MAX) lineBreakMode:UILineBreakModeWordWrap]; 

    CGSize cs2 = [caption sizeWithFont:captionFont]; 
    CGSize ts2 = [text sizeWithFont:textFont]; 
    
    [mainTextColor set];    
    CGRect c = CGRectMake(5.0, 5.0, f.size.width-10.0, cs.height+5.0);
    [caption drawInRect:c withFont:captionFont lineBreakMode:UILineBreakModeWordWrap];
    
    [secondaryTextColor set];
    if (ts2.width+cs2.width+15.0 < f.size.width-10) 
    {
        CGPoint p = CGPointMake(cs.width+10.0, 5.0);
        [text drawAtPoint:p withFont:textFont];
    }
    else
    {
        CGRect r = CGRectMake(5.0, cs.height+10.0, f.size.width-10.0, f.size.height-cs.height-15.0);
        [text drawInRect:r withFont:textFont lineBreakMode:UILineBreakModeWordWrap];
    }
}

As before, we obtain copies of the fonts we want to draw in, as well as the colors to use for the individual texts (we’ll draw the caption in black, but the body text in a slightly lighter gray). We also do the same math to obtain the rendered sizes of out text - except we don't need the ts value this time around - our cell is already sized accordingly, so we can just draw the body text without regard for its actual height.

First we draw the caption, at offset 5/5 of our cell. Next, we check whether caption and body fit on one line. If so, we draw the body text to the right of the caption and are done. If not, we’ll draw it below, word-wrapped to the appropriate width.

Finally, there’s some boilerplate plumbing code, we need to implement property getters and setters, and also initialize and dealloc our cell:

@implementation CaptionAndTextCell

- (id)initWithFrame:(CGRect)frame 
{
    if (self = [super initWithFrame:frame]) 
    {
        self.opaque = YES;
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (NSString *)caption { return caption; }

- (void) setCaption:(NSString *)aCaption
{
    caption = [[aCaption stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];
    [self setNeedsDisplay];
}

- (NSString *)text { return text; }

- (void) setText:(NSString *)aText
{
    text = [[aText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] retain];
    [self setNeedsDisplay];
}

- (void)dealloc 
{
    [caption release];
    [text release];
    [super dealloc];
}

/* … */

@end;

and with that, we’re done. (in my app, and in the screenshots shown, i also add a slight gradient to the background, to round things off; i’ll save that as exercise for the reader.

I hope you found this a helpful overview on creating a custom UITableViewCell implementation and on measuring and rendering texts. Make also sure to keep an lookout for “FeedOne”, my first and very simplistic app that will use this class, due on the AppStore any month now… ;)

SVN Repositories for Delphi Prism Users at code.remobjects.com

{#} by marc hoffman 04/10/09 10:49:31 am, 181 words, Categories: Oxygene, .NET, Visual Studio, Cocoa

Next to ShineOn, which Carlo blogged about going live on SVN last week, we've set up two more projects on code.remobjects.com to host bot RemObjects-provided and user-contributed content:

  • Delphi Prism Templates will provide a space for project and item templates for Delphi Prism that are not (whether yet, or ever) part of the core product. We're staring the repository off with a suite of templates for Microsoft's new MVC framework for ASP, as well a project template for Monobjc. But we hope that members of the Delphi Prism community will contribute their own templates, as well.
  • Delphi Prism Aspects will provide a place for for a suite of standard Aspects based on our new Cirrus AOP framework that will be shipping with Delphi Prism in May. Once again, we'll be providing some aspects form our side (such as the Monobjc property aspect demoed in this blog post, but are hoping for a vibrant community contribution, as well.

Of course we'd also love to see more contribution to ShineOn, the VCL compatibility layer for Delphi Prism, as well.

Enjoy,
marc

| Next >

 

marc hoffman

Chief Software Architect &
Spare-time Photographer

mh

Links

Twitter

marc hoffman (follow)
    loading...
Mike Orriss (follow)
    loading...

Navigation

XML Feeds 

Who's Online?

  • Guest Users: 10