• 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: How do I copy a view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I copy a view?


  • Subject: Re: How do I copy a view?
  • From: Mike Abdullah <email@hidden>
  • Date: Fri, 11 Jul 2008 10:49:31 +0100

Well assuming this so-called "UIButton" is a view class of your own creation, why are you using NSArchiver but then NSKeyedUnarchiver (keyed is recommended for all modern apps). The more common Cocoa approach is not to "copy" the view, but instead have it in its own dedicated nib where you can load a new copy as you need it.

Mike.

On 11 Jul 2008, at 05:07, Philip Dhingra wrote:

Sorry, I should've elaborated by "breaks." The application just stops. If I
put a break point at that spot, and try stepping over, nothing happens. I
can press it over and over again, nothing.


On Thu, Jul 10, 2008 at 10:28 PM, Graham Cox <email@hidden> wrote:

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@hidden)

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:
This email sent to email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >How do I copy a view? (From: "Philip Dhingra" <email@hidden>)
 >Re: How do I copy a view? (From: Graham Cox <email@hidden>)
 >Re: How do I copy a view? (From: "Philip Dhingra" <email@hidden>)

  • Prev by Date: Re: Setting DPI of image data
  • Next by Date: NSImage Crash
  • Previous by thread: Re: How do I copy a view?
  • Next by thread: Goofy behavior with CICheckerboardGenerator filter and transparency
  • Index(es):
    • Date
    • Thread