• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Array operators [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array operators [SOLVED]


  • Subject: Re: Array operators [SOLVED]
  • From: Julio Cesar Silva dos Santos <email@hidden>
  • Date: Wed, 5 Apr 2006 19:02:01 -0300

Use a value transformer to add 1 to the value, see <http:// developer.apple.com/documentation/Cocoa/Conceptual/ ValueTransformers/index.html>.

mmalc

Thanks for the reply, it worked smoothly. This is the code I wrote in case one day someone will need it:


PositionTransformer.h
=====================

#import <Cocoa/Cocoa.h>


@interface PositionTransformer : NSValueTransformer {

}

@end

PositionTransformer.m
=====================

#import "PositionTransformer.h"


@implementation PositionTransformer

+ (Class)transformedValueClass
{
	return [NSString class];
}

+ (BOOL)allowsReverseTransformation
{
	return NO;
}

- (id)transformedValue:(id)value
{
	if (value == nil)
	{
		return nil;
	}
	if ([value respondsToSelector: @selector(intValue)])
	{
		int intIndex = [value intValue];
		NSString * position = [NSString stringWithFormat:@"%d",intIndex + 1];

		return position;
	} else
	{
		return [NSString stringWithString:@""];
	}
}
@end


Julio Cesar Santos email@hidden eMac 1GHz ComboDrive 1GB RAM Linux User #359973 _______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: How to copy without losing information
  • Next by Date: Re: Making an iTunes style bar
  • Previous by thread: Re: Predicates: Trying to filter against max()
  • Next by thread: NSSaveOperationType in prepareSavePanel
  • Index(es):
    • Date
    • Thread