On Thu, 26 Feb 2009 08:49:57 -0600, I. Savant <idiotsavant2...@gmail.com> wrote:
- (IBAction)seek:(id)sender { // We have to figure out speed and direction BOOL forward; int factor; // The sender (based on its tag) tells us this ... int tag = [sender tag]; // or NSInteger tag = [sender tag]; switch (case) { case 1001: // seek back forward = NO; factor = 1; break; case 1002: // seek back FAST forward = NO; factor = 2; break; case 1003: // seek forward forward = YES; factor = 1; break; case 1004: // seek forward FAST forward = YES; factor = 2; break; default: forward = YES; factor = 1; break; } // Now tell the media controller what to do [mediaController seek:forward withFactor:factor]; // Maybe update the UI [self updateUI]; // Maybe do some more complicated things with other arguments ... }
Depending on your scenario, you might be able to encode the different cases into bitfields. The above function then turns into something like this: typedef union { int tag; struct { unsigned forward:1; unsigned factor:4; } fields; } MyCases; - (IBAction)seek:(id)sender { MyCases cases; cases.tag = [sender tag]; [mediaController seek:cases.fields.forward withFactor:cases.fields.factor]; [self updateUI]; } You have to write a small utility to figure out which tag value encodes which field options, but that's a small price to pay. Alternatively, you can encode bitfields manually: #define FORWARD_FIELD_MASK 0x0010 #define FACTOR_FIELD_MASK 0x000F And do the bit-shifting/masking yourself. --- Peter _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com