Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Badges

Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Duncan C

About

Username
Duncan C
Joined
Visits
2,488
Last Active
Roles
Tutorial Authors, Registered Users
Points
375
Badges
18
Posts
8,031
Location
Northern Virginia
  • NSMutableArray removing object

    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.
    To give a complete picture: Make the for loop run backwards:
    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.
    Tidane
  • Having problems coding some math.

    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.
    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.)


    herm57
  • Custom ModalViewController?

    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.
    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.)

    it's also scary that they're using objc_setAssociatedObject. They're mucking around in the guts of iOS. That tends to lead to very fragile code. When Apple changes something internally, your code doesn't work any more. Here is a quote from the Apple document on the Mac OS Objective C runtime that gives you an idea of the potential changes:
    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.
    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.

    I would shy away from the library you're looking at for those reasons.

    What I've done to create part-screen modal view controller looks on the iPhone is as follows:

    Create a UIView that's the full size of the screen. Set it's opaque property to FALSE and set its background color to black at 50% opacity. Let's call it the modal mask view. Add that view to your view controller on top of all the rest of your contents. Add a modal view inside that modal mask view, with a rounded rectangle border and whatever contents you want.

    Hook up an outlet to your modal mask view. Set the modal mask view to hidden by default.

    When it's time to show you modal view, use a UIView block animation to fade your modal mask view from transparent to fully opaque. You can also animate the content view into place from the bottom like a normal modal, but that's more work.

    When you are done with the modal, reverse the set of animations you used to show it (slide the view off the screen, then fade the mask view back to transparent before hiding it.)

    My approach requires custom code in your view controller, so it's not that portable. If it's something you used a lot, you could create a subclass of UIViewController that supported this simulated view controller, and then use that class as the basis of your view controllers.

    Edit: If you're willing to restrict your apps to iOS 5 or later, you can use the child view controller support in the OS and create your own part-screen modal quite easily.
    vishwakrma
  • Playlist title

    I've never used playlists before. I searched in the Xcode docs and found the answer in less than 30 seconds
    Your search term is "MPMediaPlaylist Class Reference" The first page of that article has what you need.
    carlandrews
  • Problem with an UIView not showing in the correct position inside an UIViewController

    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 :)
    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.

    The pixel dimensions of the iPhone 5 and 4" iPod are 640x1136 (That's the full screen size including the status bar and title bar)

    However, the coordinate system on these devices is in points. The iPhone 5's screen is 320x568 points. When you position things, or specify sizes, you use points, not pixels. If the image you're drawing at a given location is available in an @2x form, it gets rendered at full resolution. If not, the non-retina image occupies the same space but it's pixels are doubled.

    In practice, you ignore the extra resolution on retina devices, and pretend it doesn't exist. Then you supply retina resolution art with the @2x specifier as well as non-retina art and the system uses the higher-res art on retina devices.
    Mikk