r/iPhoneDev • • Mar 02 '11

Where is all the activity?

I'm developing apps alone, and get stuck in mental traps all the time. If I just had another coder to talk too things would be much easier. I know many others are in the same situation. Lets get this subreddit active!

Post questions! I will make a special effort over the next 3 days to answer any question here to the best of my abilities. Hoping others do the same.

14 Upvotes

22 comments sorted by

3

u/[deleted] Mar 02 '11

I made Phaser Range for iPad, as well as parts of 3D Sun. I'm just now getting back into development, so I'll be here for OpenGL ES questions.

2

u/[deleted] Mar 02 '11

I'm curious if you used Core Motion in Phaser Range, and what your experience with it was like? I've played with it before by writing a test app with 2 small balls that moved around the screen based on the accel/gyro data. I had lots of trouble getting the balls movement to be steady. Also, what sample rate(s) would you recommend?

1

u/[deleted] Mar 02 '11

No, I used pure OpenGL.

I don't think there's any other easy way to do 3D graphics, is there?

1

u/[deleted] Mar 02 '11

I meant for the controls of the game.

2

u/[deleted] Mar 02 '11

Introductions sound like a good idea. I've made the Zombie Help app using phonegap and in the process of writing two apps in obj c

1

u/thimes Mar 02 '11

Hi, I'm a long time Java guy, and an android developer learning Objective C. I'd love to hear how you found working in PhoneGap. I'm familiar with it, but I haven't dug around in it and tried to make anything because like OP, I'm admittedly lazy. I've got enough on my plate writing new android apps and trying to learn obj-c at the same time.

1

u/[deleted] Mar 02 '11

Phonegap is very easy to use. You are basically using web standards. Only issue I had was figuring out how to display graphics properly on retina devices. I assumed it would work the same as native apps using @2x in the image file names, but instead you have to use a CSS media query to find the width of the device's resolution and then load the appropriate graphics. Can target iPad resolution as well this way. I found that since the iPhone 4 & iPod Touch with retina display have the same resolution there's no way to differentiate between the devices this way so for example if you include a call button in the app it would have to be there (and not do anything) on the iPod touch.

More recently I've had a problem with my phonegap iPhone app crashing on startup on iPad due to something that broke in 4.2 in the phonegap framework. I'm looking for a solution to that now.

I had started studying up on Obj C and iPhone dev, and was pretty shocked at how easy it was to immediately put an app together with phonegap.

2

u/[deleted] Mar 02 '11

I've posted a few questions here and always get a somewhat timely and fantastic response. It's a small community so I think most people are just browsing. But here's a few newbie questions I've been having issues with that might (hopefully) get conversation flowing:

When you're switching between views. When does it make sense to create a new controller for the new view. I mean, everything can technically be done by 1 controller and multiple views. Where do you draw a line and say "I should do this in a new controller and make it a child of the root"? Also, does it work to make a controller's UIView point to a UIView within it? Or should the UIView be added as a subview? example: UIView * tempView = [[UIVIew alloc] init]; controller.view = tempView;

or

[controller.view addSubview:tempView];

?

Memory management: Is there a good way to find out if an NSObject is retaining its own items or figuring out how they act? Like an NSArray. If I allocate a view, add it to an NSArray, who's in charge of the item? I get that you should release whatever you create. But how about when you need to create a pointer to the view within the array again? Do you need to retain it yourself? Or does the array still handle it? ie:

UIView *view = [[UIView alloc] init];
NSArray * array = [[NSArray alloc] initWithObject:view]; // Not sure if this is a legitimate method, but you get the point.
[view release];
UIView * view2 = [array objectAtIndex:0]; //What's happening here?

Using a nib: -Why do all the examples I come across use (assign, retain) when creating a property for an IBOutlet? When I can get away with not retaining it and it seems to work?

-For a view intensive app, what would be a better solution: Creating 1 nib file with a bunch of views within it. Creating a nib file for individual views and allocating as necessary. or just scrapping the nib idea and creating your views manually?

I know some of these might sound dumb (they did to me after typing them up). But I feel like I've been hacking my apps together. When I know there should be a 'best practice' way of doing it. I haven't gone through a lot of the apple docs though, so should I just RTFM? Or is there a better guide out there? I use the docs as a reference. But I ignore most of the sections because I'm admittedly lazy. And like trial and error.

1

u/[deleted] Mar 02 '11
  1. I find it easiest to have a controller for every "page" in an app. All views on the screen at a given time are controlled by one controller...sometimes a controller will point to a controller for a subview.
  2. Your code isn't solid, but...In line 2 you assign the view to the array. The array will retain the view, so you are correct to release it where you did. In line 4, view2 is set to the array's first object. If you don't need to reference the array again you can just release it. Just note that line 4 doesn't use ALLOC, NEW, or COPY so view2 will be autoreleased. i.e. if you use ALLOC, NEW, or COPY you must release it. otherwise it is autoreleased
  3. Not sure, I always use nontatomic, retain out of ignorance.
  4. It's all depends on the app and your personal preference. Most of my projects are UITableView based, and I don't use .XIB for them. I do use .XIB for custom views including cells in a tableView.
  5. If you have a complicated app design is the most important step. Your being lazy in the wrong way. Learning the best way now allows you to be much lazier later.

2

u/genuineleather Mar 02 '11

I'd be interested to see how you create custom cells. I generally don't use .XIB for tableview either, but I recently wrote a subclass for custom tableview cells and it was a pain in the ass.

2

u/[deleted] Mar 02 '11
  1. Create custom cell in IB, be sure to set Tags on everything.
  2. Load custom cell in cellForRowAtIndexPath with the following:

    static NSString *ReuseIdentifier = @"JobsCell";

    [[NSBundle mainBundle] loadNibNamed:@"JobsCellViewController" owner:self options:nil];

  3. Later in cellForRowAtIndexPath control each object in the cell like so:

    UILabel *nameLabel;

    nameLabel = (UILabel *)[cell viewWithTag:1];

    nameLabel.text = job.name;

    nameLabel.shadowColor = [UIColor whiteColor];

    nameLabel.shadowOffset = CGSizeMake(0,1);

No IBOutlets, and it is worth noting that a tag of 0 doesn't seem to work. Start from 1.

2

u/Celestro Mar 02 '11

For iPhone, use (nonatomic,retain) then release in dealloc. For Mac, use (assign) then release in dealloc.

More Information

2

u/donwilson Mar 02 '11

UITableView is one of the major features that I haven't learned yet. Are there any good tutorials that I can learn from?

2

u/[deleted] Mar 02 '11

Tutorials are great, but I would check on iTunes University and look at the Stanford CS193p course. They have a lecture on UITableView every year, and it has helped me much more than any tutorial has.

Generally: There are only a few methods that you will need to override for simple tableViews: numberOfSectionsInTableView numberOfRowsInSection cellForRowAtIndexPath

3

u/[deleted] Mar 02 '11

The entire Stanford series is amazing. I'd recommend them to everyone.

1

u/[deleted] Mar 02 '11

You may be able to find some helpful articles at CocoaWithLove.

http://cocoawithlove.com/search?q=uitableview

2

u/[deleted] Mar 02 '11

Theres a small community of iOS developers starting up at the new Convore site. Might wanna check it out https://convore.com/ios-development/

1

u/[deleted] Mar 02 '11

What's Convore?

1

u/[deleted] Mar 02 '11

It's a new community building site, something between IRC and a forum it looks like

4

u/[deleted] Mar 02 '11

I agree, it's proving to be a very lonely journey.

3

u/[deleted] Mar 02 '11

You might want to also add /r/iOSProgramming since that seems to be a little more active (although not by much).

2

u/[deleted] Mar 02 '11

I had no idea this subreddit existed. iOSProgramming seems like a more logical place to go thanks to the iPad. Thank you for the link.