To give a complete picture: Make the for loop run backwards:One more thing to add to namanham1, be sure and start i at [arrEmptyMusterID count] and i>=0
The basic idea is that you are iterating over the array in reverse so that when you do remove an object, it doesn't screw up i.
for (int i=[arrEmptyMusteriID count]-1; i>=0; i--) {
if ([[[arrEmptyMusteriID objectAtIndex:i] objectForKey:@"musterID"] isEqualToString:@" "]) {
[arrEmptyMusteriID removeObjectAtIndex:i];
}
}
As smithdale87 says, when you do that, deleting an item from the array doesn't change the index of the remaining items. Floating point numbers are precise, but don't map exactly to decimal. The problem is that floating point numbers on computers use base 2. Only numbers that are the sums of 1/2, 1/4, 1/16, etc can be represented exactly. Just like in decimal, you can only represent numbers that are sums of n/10, n/100, n/1000, etc. In decimal, 1/3 is a repeating number, 0.333333... In binary floating point, 1/10 is a repeating value, .0001100110011001100110011 (the 0011 bit repeats endlessly, where each digit is a 1 or a zero, and represents the next smaller power of 2.)Also, you should really be using NSDecimalNumber for any calculations involving currency. Using floating point numbers will leave you prone to rounding problems stemming from the fact that floating point numbers are not all that precise.
You're not supposed to add one view controller's view to another view controller, unless you're using the new child view controller support added to iOS 5. It's possible to do so, but it requires that you do a bunch of housekeeping yourself, and it goes against Apple's design. I know of one major company that was doing that, and when Apple got wind of it, they threatened to pull them from the store. (This was a major Apple partner, so the threat was a very big deal.)samurle;419478 said:Thanks for the suggestion.
I don't know how the iOS modalViewController works exactly, but a potential problem with
just adding a subview, is that it doesn't check to see if that view is the topmost window
or the most recently visible window. Sure, it can be done, but there is more housekeeping
to make it work.
The link to the code I posted adds the custom modal view to the application's keyWindow,
which is the currently visible window:
UIWindow *thisWindow = [[UIApplication sharedApplication] keyWindow];
[thisWindow addSubview:modalViewController.view];
What I don't understand is why they're using associative object referencing.
Is this needed to retain the modal view? I thought calling addSubview retains
the modal view, so why use associative referencing? They also use the view's tag
to track the window for dismissal, so there's no need to save it anywhere.
That is for Mac OS, not iOS, but it gives you an idea of the changes that have happened to the Objective C runtime fairly recently. Apple completely removed functions that used to work.The low-level Objective-C runtime API is significantly updated in Mac OS X version 10.5. Many functions and all existing data structures are replaced with new functions. The old functions and structures are deprecated in 32-bit and absent in 64-bit mode.
iOS uses "points" to describe the size and coordinates on the screen. A point is always the same physical size. On non-retina devices it is the same size as a pixel. On retina devices it's 2x2 pixels.I have another question about xcode and interface builder, I've set the 4-inch in both the device and IB and it works properly, but why even if the resolution of the 4-inch device is 640x960 the IB is showing me 320x568 ? I'm not sure how to set the properly images (which have been done considering 640x960 screensize) and this, thanks :)