Build error on lottery.m example


#1

I’m doing the second lottery code example, which modifies the first lottery.m file on page 49-50.
I get a build error on the last for loop

for (LotteryEntry *entryToPrint in array) {

error: nested functions are disabled, use -fnested-functions to re-enable

I am using Xcode 2.4 under OSX 10.4.11
I assume that loop syntax is not supported in my version of Xcode.
I could not find anything in the documentation about -fnested-functions. What is it?
I had to provide the workaround of using the standard incremented for-loop.

for (i=0; i< 10; i++) {
LotteryEntry *entryToPrint = [array objectAtIndex:i];
NSLog(@"%@", entryToPrint);
}


#2

[quote=“dspencer”]I’m doing the second lottery code example, which modifies the first lottery.m file on page 49-50.
I get a build error on the last for loop

for (LotteryEntry *entryToPrint in array) {

error: nested functions are disabled, use -fnested-functions to re-enable

I am using Xcode 2.4 under OSX 10.4.11
[…][/quote]

IIRC fast enumeration is only available on Leopard (and higher ofc), see developer.apple.com/leopard/over … ivec2.html


#3

Thanks for the fast reply.

I figured it was something like that. I will eventually upgrade my OS.
I’m a stubborn holdout for upgrades since I can do much of what I want with the older system.

I’m just starting cocoa, so when I get serious I will upgrade.
Plus I can’t use an iPad without Leopard.