I assume that UIButton is an iPhone class. Well, we can't talk about that...

If it were an NSView, archiving works for copying views, but maybe UIButtons aren't archivable? (Guessing, obviously).

When you say it "breaks" what do you mean if you get no error message?


Graham


On 11 Jul 2008, at 1:21 pm, Philip Dhingra wrote:

I'm trying to add a copy of a view as a subview to the parent view. This is
what I tried:

UIButton* firstButton = [[UIButton alloc] initWithFrame:CGRectMake(0,0,360,
360)];

NSData *btnData = [NSArchiver archivedDataWithRootObject:firstButton]; //
Breaks Here

[parentView addSubview:firstButton];

UIButton *twin = [NSKeyedUnarchiver unarchiveObjectWithData:btnData];

[parentView addSubview:twin];

It breaks when I try to archive the object, and I don't get any error
message in the console. Maybe there's another error console (I'm new to
Cocoa) that shows what's wrong.

Is there any way to copy or mirror a view?

Thanks,

Phil
_______________________________________________

Cocoa-dev mailing list ([email protected])

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/graham.cox%40bigpond.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [EMAIL PROTECTED]

Reply via email to