Results 1 to 4 of 4
Discuss CGPoint into an NSArray? at the iPhone Developer Exchange - Hackint0sh.org; In coding for the iPhone, I've come across this problem.. I know you need to ...
  1. #1
    Newbie Array

    Join Date
    Jul 2008
    Location
    denver
    Posts
    8
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default CGPoint into an NSArray?

    In coding for the iPhone, I've come across this problem..

    I know you need to put Objects into NSArrays (and variants), and a CGPoint being a struct will not work. I don't want to use regular C array notation because I'd like to utilize the dynamic power of the NSMutableArray. I'd rather not have to encapsulate the CGPoint struct in a class.. it just seems so unnecessary.

    What to do?



  2. #2
    Senior Professional Array

    Join Date
    Jul 2007
    Posts
    151
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    16

    Default

    You will have to wrap it in a class. Lemme know if there's a NSStringFromCGPoint() or NSValue class that works for you. (I'm not on my dev machine at the moment.)

  3. #3
    Developer Array

    Join Date
    Jul 2008
    Posts
    471
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    29

    Default

    it appears (more often than not) that you will have to do things you dont want to, or shouldnt have to, in the official iphone sdk. Not to say that it follows any pattern or reason devoted to any legitimate thought process.

  4. #4
    Senior Professional Array

    Join Date
    Jul 2007
    Posts
    151
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    16

    Default

    The reason for the class wrapper is simple and expected.

    There are three options:
    1) Make a simple C array. (or linked list of arrays)
    2) Make a class of NSMutableArray which handles only struct instead of objects.
    3) Wrap the structs in objects and put them in NSMutableArray.

    The problem is #1 is that he wanted the dynamic insertion features of NSMutableArray.
    The benefit of #1 is that it's the fastest because you optimize everything to your situation.

    The problem with #2 is that Apple would need to write a new class AND it'll be slower than doing it all in C. There is little reason to do this really especially since it's obvious there's a lot of more important stuff Apple still needs to work on in the iPhone.

    Based on what typewriter said, #3 was the most reasonable for his tasks. I didn't say it was the best idea. It's simply good enough for most people.

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 11:16 PM.
twitter, follow us!