Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTom Bakker
2,132 PointsiOS Image Sequence Importing (need help with debugging)
I'm following the iOS Development Track and decided to do the extra task and try to make a random quotes application. One of the things I tried to recreate was the animation via an image sequence. But because my sequence consisted of 118 images I decided it'd be best if i wrote code to import them into an NSArray. But, quite disappointingly, it didn't work. I have no idea what all the debug information means. This is the script I wrote to get the information.
```Objective C
NSMutableArray *waveImageSequence = [[NSMutableArray alloc] initWithCapacity:118];
for (int i = 0; i < 118; i++) {
if (i < 10){
NSString *imageName = [NSString stringWithFormat:@"wave0000%d", i];
waveImageSequence[i] = [UIImage imageNamed:imageName];
} else if (1 < 100){
NSString *imageName = [NSString stringWithFormat:@"wave000%d", i];
waveImageSequence[i] = [UIImage imageNamed:imageName];
} else {
NSString *imageName = [NSString stringWithFormat:@"wave00%d", i];
waveImageSequence[i] = [UIImage imageNamed:imageName];
}
}
self.waveImageView.animationImages = [NSArray arrayWithArray:waveImageSequence];
self.waveImageView.animationDuration = 5.0f;
self.waveImageView.animationRepeatCount = 0.0f;
[self.waveImageView startAnimating];
waveImageView is the property linking to my imageView in the storyboard.
And this is the file the debugger shows
```Objective C
//
// main.m
// RandomQuotes
//
// Created by Tom Bakker on 13-02-14.
// Copyright (c) 2014 Tom Bakker. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TBAppDelegate.h"
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([TBAppDelegate class]));
}
}
I hope someone can help me out! Thank you very much!
2 Answers
Thomas Nilsen
14,957 PointsDo this, then run the program again: http://imgur.com/F7hpMUq
Instead of the program going directly to main.m, it will stop at the line where the problems are (most of the time)
Thomas Nilsen
14,957 PointsThe silly mistakes are often the ones that are hardest to find ; )
Tom Bakker
2,132 PointsTom Bakker
2,132 PointsOh that's great! I used that and I almost instantly found that I typed a 1 instead of an i at the second elseif. How could I have missed that? Haha