Re: NSDateFormatter not working on iOS 5.

2012-03-23 Thread Heath Borders
 I will need to think about the best current workaround for this, but right 
 now I am (and have been) swamped, sorry.

I've tried the following code and it seems to work for me.  Can you
think of any reason why it might not work?  As I understand from the
unicode standard [1], V is supposed to prefer the metazone timezone
abbreviation, which is what my users commonly expect (in America: EST,
EDT, CST, CDT, MST, MDT, PST, PDT, etc; in India: IST).

Thanks!

NSLocale *indianEnglishLocale = [[[NSLocale alloc]
initWithLocaleIdentifier:@en_IN] autorelease];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@Asia/Kolkata];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:indianEnglishLocale];
[dateFormatter setDateFormat:@V]; // or @zzz
[dateFormatter setTimeZone:timeZone];

NSLog(@V date string: %@, [dateFormatter stringFromDate:[NSDate date]]);

[1] http://unicode.org/reports/tr35/tr35-10.html#Date_Format_Patterns

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, Feb 13, 2012 at 12:09 PM, Peter Edberg pedb...@apple.com wrote:

 On Feb 2, 2012, at 7:56 AM, John Joyce wrote:


 On Feb 2, 2012, at 2:20 AM, Peter Edberg wrote:


 On Jan 31, 2012, at 2:35 PM, cocoa-dev-requ...@lists.apple.com wrote:
 --

 Message: 1
 Date: Tue, 31 Jan 2012 14:10:13 -0600
 From: Heath Borders heath.bord...@gmail.com
 To: cocoa-dev cocoa-dev@lists.apple.com

 Peter,

 If I set the locale to en_IN shouldn't that show the short time zone?

 NSLocale *indianEnglishLocale = [[[NSLocale alloc]
 initWithLocaleIdentifier:@en_IN] autorelease];
 NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@Asia/Kolkata];
 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] 
 autorelease];
 dateFormatter.locale = indianEnglishLocale;
 dateFormatter.dateFormat = @z;
 dateFormatter.timeZone = timeZone;

 NSLog(@date string: %@, [dateFormatter stringFromDate:[NSDate date]]);
 NSLog(@time zone abbreviation: %@, [timeZone
 abbreviationForDate:[NSDate date]]);

 output:

 date string: GMT+05:30
 time zone abbreviation: IST

 -Heath Borders


 Heath,
 Yes, you are correct, for the example you provided above, [dateFormatter 
 stringFromDate:[NSDate date]] *should* use the short time zone name IST. 
 The fact that it does not is due to a deficiency in the en_IN locale data 
 in the versions of CLDR data used by ICU in the current OSX and iOS 
 releases (CLDR 1.9.1 and 2.0 respectively). The en_IN locale in those 
 CLDR versions did not override or supplement any of the timezone name data 
 from the base en locale, whose default content is for en_US.

 This is already fixed for the CLDR 21 release coming in a few days. That is 
 being incorporated into ICU 49 which will be picked up in future OSX and 
 iOS releases.

 - Peter E


 Is there any recommended workaround approach for this kind of scenario until 
 those updates are incorporated?
 More specifically, how would one best implement a workaround that would be 
 easily overridden by (or not clash terribly) the fix when it is eventually 
 incorporated into a release?
 Any best practices or recommendations in that area?

 I will need to think about the best current workaround for this, but right 
 now I am (and have been) swamped, sorry.
 - Peter E




 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: issues using encodeWithCoder: with NSAttributedString for iOS

2012-02-26 Thread Heath Borders
I don’t know of an easy workaround. Back in the day I would have suggested
creating a category on CGColor that adds the required archiving methods,
but doing this will get you rejected from the App Store. You may need to
write a function that walks through a mutable attributed string and finds
all color objects and replaces them with something serializable, and
another function that reverses this.


How do you create a category for a Foundation type that isn't an
Objective-C class? And why would that get you rejected?

Sent from my iPad

On Feb 27, 2012, at 12:21 AM, Jens Alfke j...@mooseyard.com wrote:


On Feb 26, 2012, at 9:44 PM, Michael Swan wrote:

the thing that doesn't make any sense is that if NSAttributedString
conforms to the NSCoding protocol it must be able to fully pack itself up
when encodeWithCoder: is called on it which means that it should already be
taking care of encoding the CGColor in whatever way necessary.


Archiving doesn’t work that way. Every object asks its instance variables
to archive themselves; it’s not in charge of how they do it.
NSAttributedString is, basically, an array of dictionaries, each of which
can have arbitrary values in it. NSAttributedString itself doesn’t know or
care what those keys or values are. (Note that NSAttributedString is
implemented in the Foundation framework, which is lower level than UIKit.)

What you’re running into is that CGColor isn’t archivable — it doesn’t
implement the protocol methods like -encodeWithCoder:. So the attributed
string is asking the attribute dictionary to archive itself, and the
dictionary asks its keys and values to archive themselves, and the CGColor
object fails.

I don’t know of an easy workaround. Back in the day I would have suggested
creating a category on CGColor that adds the required archiving methods,
but doing this will get you rejected from the App Store. You may need to
write a function that walks through a mutable attributed string and finds
all color objects and replaces them with something serializable, and
another function that reverses this.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Stop developer tools access... and gdb-i386-apple-darwin... alerts

2012-02-03 Thread Heath Borders
I recently upgraded to 10.7.3, and when I try to debug my iOS project
in the simulator for the first time after logging in, I'm prompted
with the following two alerts:

Developer Tools Access needs to take control of another process for
debugging to continue. Type your password to allow this.
http://i.stack.imgur.com/GeKA8.png

gdb-i386-apple-darwin needs to take control of another process for
debugging to continue. Type your password to allow this.
http://i.stack.imgur.com/sg9rv.png

My user is an admin user.  I never saw these alerts before.  How do I
get them to stop?

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

On iOS5 simulator and device, NSDateFormatter doesn't show time zone abbreviation for Asia/Kolkata for the z or zzz specifier.

2012-01-31 Thread Heath Borders
On iOS5 simulator and device, NSDateFormatter doesn't show time zone
abbreviation for Asia/Kolkata for the z or zzz specifier.

NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@Asia/Kolkata];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = @z; // or @zzz
dateFormatter.timeZone = timeZone;

NSLog(@date string: %@, [dateFormatter stringFromDate:[NSDate
date]]); // GMT+05:30, expected IST
NSLog(@time zone abbreviation: %@, [timeZone
abbreviationForDate:[NSDate date]]); // IST

I expect the above code to output

IST
IST

but it outputs

GMT+05:30
IST

Is this a bug? Am I doing something wrong?  People have mentioned that
NSDateFormatter has bugs, especially when a time zone is specified in
the format string.  Could this be one of those bugs?[1]

[1] http://stackoverflow.com/a/838934/9636

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSDateFormatter not working on iOS 5.

2012-01-31 Thread Heath Borders
Peter,

If I set the locale to en_IN shouldn't that show the short time zone?

NSLocale *indianEnglishLocale = [[[NSLocale alloc]
initWithLocaleIdentifier:@en_IN] autorelease];
NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@Asia/Kolkata];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.locale = indianEnglishLocale;
dateFormatter.dateFormat = @z;
dateFormatter.timeZone = timeZone;

NSLog(@date string: %@, [dateFormatter stringFromDate:[NSDate date]]);
NSLog(@time zone abbreviation: %@, [timeZone
abbreviationForDate:[NSDate date]]);

output:

date string: GMT+05:30
time zone abbreviation: IST

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, Nov 21, 2011 at 1:54 AM, Peter Edberg pedb...@apple.com wrote:

 On Nov 17, 2011, at 10:14 AM, Matt Neuburg wrote:

 On Wed, 16 Nov 2011 14:43:55 -0800, Peter Edberg pedb...@apple.com said:
 ...

 The issue is this: With the *short* timezone formats as specified by z 
 (=zzz) or v (=vvv), there can be a lot of ambiguity. For example, ET for 
 Eastern Time could apply to different time zones in many different 
 regions. To improve formatting and parsing reliability, the short forms are 
 only used in a locale if the cu (commonly used) flag is set for the 
 locale. Otherwise, only the long forms are used (for both formatting and 
 parsing).

 For the en locale (= en_US), the cu flag is set for metazones such as 
 Alaska, America_Central, America_Eastern, America_Mountain, 
 America_Pacific, Atlantic, Hawaii_Aleutian, and GMT. It is *not* set for 
 Europe_Central.

 However, for the en_GB locale, the cu flag *is* set for Europe_Central.

 So a formatter set for short timezone style z or zzz and locale en or 
 en_US will not parse CEST or CET, but if the locale is instead set to 
 en_GB it *will* parse those. The GMT style will be parsed by all.

 ...

 Thanks; I suspected that something like this might be the case. But the 
 result, as I pointed out in my bug report (10447767), is that you can't 
 round-trip the abbreviations that the system itself gives you:

    NSDictionary* d = (NSDictionary*)CFTimeZoneCopyAbbreviationDictionary();
    for (NSString* aZone in d.keyEnumerator)
        NSLog(@%@ %@, aZone, [dateFormatter dateFromString:
           [NSString stringWithFormat:@2011-11-15 06:50:59.735 %@, aZone]]);

 These are *your* abbreviations (by you I mean the system) that aren't 
 working. If they aren't going to work why are you giving them to me? Surely 
 there should be some call that provides me with a list of *legal* 
 abbreviations. m.



 Yes, there is a disconnect here. The dictionary returned by 
 CFTimeZoneCopyAbbreviationDictionary (and by +[NSTImeZone 
 abbreviationDictionary]) is a standard internal mapping that does not depend 
 on locale and is not built from the abbreviations used by ICU, and always 
 maps ambiguous zone abbreviations to a particular zone name (as noted in the 
 documentation) regardless of locale. This is not particularly useful for your 
 purposes.

 What would be more useful in this case is function that takes a locale 
 parameter, and returns a dictionary of the abbreviation mappings that are 
 meaningful in that locale. This would be built from the locale-specific 
 abbreviations used by ICU. If you agree, please file an enhancement request.

 - Peter E

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Why doesn't UIViewController retain its UISearchDisplayController

2011-10-06 Thread Heath Borders
In the UIViewController documentation about the
searchDisplayController property [1] it says:

If you create your search display controller programmatically, this
property is set automatically by the search display controller when it
is initialized.

And when I create my UISearchDisplayController thusly:

[[[UISearchDisplayController alloc] initWithSearchBar:searchBar
contentsController:self] autorelease];

-[UIViewController searchDisplayController] is not nil. However, it is
nilled out after the event loop finishes, which causes the search
display controller not to show when I touch inside the search bar.
Nothing crashes. This is very weird. If I omit the call to
autorelease, everything works:

[[UISearchDisplayController alloc] initWithSearchBar:searchBar
contentsController:self];

However, leaks the UISearchDisplayController (I verified this with
Instruments). Since the searchDisplayController property is marked as
(nonatomic, retain, readonly) I expect that it would retain the
UISearchDisplayController after it is set.

This stackoverflow article [2] is related.  I cross-posted this
question on stackoverflow. [3]

[1] 
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/searchDisplayController
[2] http://stackoverflow.com/q/2395272/9636
[3]


-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Managed Object Model versions

2011-09-30 Thread Heath Borders
You specify a URL for the persistent store when you create it. Just find the
store at that URL.

-Heath
On Sep 30, 2011 12:33 AM, Luke Sneeringer lukesneerin...@gmail.com
wrote:
 Hey all,
 I am working on writing my first Core Data application. I made an entity,
did some work to test it, and then made another (linked) entity.
 The problem is now I'm totally stuck, because when I try to do anything
that affects Core Data, I get a completely unhelpful error message:

 The managed object model version used to open the persistent store is
incompatible with the one that was used to create the persistent store.

 Well, I Googled this, and there's some discussion about making migrations.
I don't want to do that. I just want to blow away the old data store -- get
it out of the filesystem and have the application make a new one.
 However, I can't figure out how to do this. I found a blog entry
suggesting that I look in ~/Library/Application Support/Application Name/,
but my application doesn't seem to have made a folder in
~/Library/Application Support/ at all.

 So...how can I get rid of my old persistent store? It doesn't have to be
programmatic -- in fact, I'd prefer it not be programmatic. I just want to
wipe it off the disk.

 Help!

 Thanks,
 Luke Sneeringer___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Calling -addObserver:forKeyPath:… more than once

2011-08-26 Thread Heath Borders
You must call remove as many times as you call add.  Otherwise,
subclasses and superclasses would interfere with each other's
observations.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Fri, Aug 26, 2011 at 4:34 AM, Rick Mann rm...@latencyzero.com wrote:
 Is -addObserver:forKeyPath:… idempotent? I called it multiple times with the 
 same parameters, but called -removeObserver:forKeyPath: only once, and the 
 object continued to receive KVO notifications.

 After adding code to ensure -addObserver:forKeyPath:… was only called once, 
 -removeObserver:forKeyPath: seemed to work as expected.

 I couldn't find any clear indication in the docs or searching online, 
 although I did find some things that indicate these APIs rather do suck.

 --
 Rick

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Sharing a persistent store between iOS and Mac

2011-08-26 Thread Heath Borders
I've done something similar in two of my projects.  However, I only shared
the sqlite file, not the momd.

I created a command-line build tool, and generated a sqlite coredata store
with it. Then I copy the sqlite into my iOS project and add it to the Copy
Bundle Resources phase.  I do NOT copy the momd.  I reference the same
xcdatamodel file in both projects and each one builds its own copy. Perhaps
the sqlite file is shareable but the momd is not?

-Heath
On Aug 25, 2011 3:31 PM, Fritz Anderson fri...@manoverboard.org wrote:
 iOS 4.3 Simulator, Xcode 4.1, Lion 10.7.1

 I'm having trouble generating a Core Data store and opening it in an iOS
app (in the Simulator so far).

 My iOS app has to initialize a large, read-only dataset — a 12,000-word
vocabulary with definitions. In my early drafts, with 6000 words, I had it
parse a text file, but that took alarmingly long, and the watchdog timer
would probably kill it if I attempted the full dictionary.

 So if I'm initializing an SQLite Core Data store anyway, why not do so at
build time, with a command-line tool on the Mac side?

 So I have two targets. They share one managed-object class and a data
model. The builds for both compile the data model into a .momd. It's not the
same momd, but VersionInfo.plist in both is identical. The command-line tool
takes the .momd and the vocabulary text, and produces vocab.sqlite in
SRCROOT. Using Navicat for SQLite Lite, I verified that the contents of the
file are (as far as I can tell) what I expect.

 The iOS target copies vocab.sqlite as a resource. I verified (by eye and
by an assertion in code) that it is in the .app bundle. I reviewed the build
logs and verified that the .sqlite file came from the place to which the
command-line tool wrote.

 I get The model used to open the store is incompatible with the one used
to create the store when the iOS app tries to add vocab.sqlite to the
persistent store coordinator.

 There is only one .momd in the .app bundle. The command-line tool takes a
.momd as an argument; I've tried pointing it at the .momd inside the bundle;
still incompatible.

 From everything I know to check, I'm doing this right. I've found nothing
to suggest you can't put a Mac-generated store into an iOS app, and much to
suggest that you should. I'm stymied. What should I try next?

 — F

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Core Data Concurrency Issues

2011-08-04 Thread Heath Borders
A managed object context needs to be used and created from the same thread.
Create and use childContext in a single dispatchAsync block.

-Heath
On Aug 4, 2011 5:32 PM, Jeff Kelley slauncha...@gmail.com wrote:
 I’m having some issues with concurrency with Core Data. I create an object
 that has a to-many relationship with another object (which in turn has a
 to-one reciprocal relationship with the first object), then dispatch_async
 onto a private queue. In that queue, I use a separate managed object
 context, which I’ve created earlier and only use within that queue. Here’s
a
 snippet:

 ParentObject *parent = [NSEntityDescription
 insertNewObjectForEntityName:@ParentObject]
 inContext:[self moc]];

 NSManagedObjectID *objectID = [parent objectID];

 dispatch_async(dedicatedQueue, ^{
 // Note: childContext is an NSManagedObjectContext that has been created
 earlier and is only used within this queue.
 ParentObject *parent = [childContext objectWithID:userID];

 for (NSDictionary *jsonDict in allChildDicts) {
 ChildObject *child = [NSEntityDescription
 insertNewObjectForEntityName:@ChildObject]
 inContext:childContext];
 [parent addChildObject:child];
 }
 });


 If I try to save the context within the dedicated queue, I get validation
 errors on the child objects with the text “Dangling reference to an
invalid
 object.”

 It appears to work correctly if I create the parent object within the
 dedicated child queue. So, what is the proper way to create these objects
on
 the main queue and then update them in the background? Thanks in advance.

 Jeff Kelley
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController Fast forward

2011-07-29 Thread Heath Borders
You could do key-value observing on currentPlaybackRate.

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfp/MPMediaPlayback/currentPlaybackRate

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Thu, Jul 28, 2011 at 2:06 PM, Steve Kostrey st...@askvideo.com wrote:
 I've implemented MPMoviePlayerController (iPhone/iPad) and I'm playing videos 
 without trouble but I'm not sure how to receive an event from the Fast 
 forward overlay button.
 I've tried everything the documentation suggests about remote control but I'm 
 not sure that's the way.

 I've tried the following code:

 [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
 [self becomeFirstResponder];

 - (BOOL)canBecomeFirstResponder {
  return YES;
 }

 - (void)remoteControlReceivedWithEvent:(UIEvent *)event {

  if( event.type == UIEventTypeRemoteControl ) {
      NSLog(@sub type: %d, event.subtype);
  }
 }

 Not sure where to place this (and when I place it in the header I get 
 redefinition errors):

 typedef enum {
  // available in iPhone OS 3.0
  UIEventSubtypeNone                              = 0,

  // for UIEventTypeMotion, available in iPhone OS 3.0
  UIEventSubtypeMotionShake                       = 1,

  // for UIEventTypeRemoteControl, available in iPhone OS 4.0
  UIEventSubtypeRemoteControlPlay                 = 100,
  UIEventSubtypeRemoteControlPause                = 101,
  UIEventSubtypeRemoteControlStop                 = 102,
  UIEventSubtypeRemoteControlTogglePlayPause      = 103,
  UIEventSubtypeRemoteControlNextTrack            = 104,
  UIEventSubtypeRemoteControlPreviousTrack        = 105,
  UIEventSubtypeRemoteControlBeginSeekingBackward = 106,
  UIEventSubtypeRemoteControlEndSeekingBackward   = 107,
  UIEventSubtypeRemoteControlBeginSeekingForward  = 108,
  UIEventSubtypeRemoteControlEndSeekingForward    = 109,
 } UIEventSubtype;


 Bottom line is I would love to receive the FF event. Has anyone successfully 
 done this?



 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


ANN: HBCollections Blocks Categories

2011-07-29 Thread Heath Borders
Objective-C categories for functional data structure traversal with
blocks. The interface was inspired by Javascript Array Iteration
Methods. The implementation was inspired by Mike Ash's Implementating
Fast Enumeration Friday QA.

https://github.com/hborders/HBCollections

I encourage any feedback about ways to make this more efficient or any
other convenience APIs or basic functional APIs I could add.

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why are these objects still faults?

2011-07-19 Thread Heath Borders
Is your topic node self-referential? Maybe CoreData doesn't prefetch
circular references.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Jul 19, 2011 at 12:21 AM, Gideon King gid...@novamind.com wrote:
 Hi, I'm doing a fetch of some objects like this:

 entity = [NSEntityDescription entityForName:kNMTopicNodeEntityKey 
 inManagedObjectContext:[self managedObjectContext]];
 request = [[NSFetchRequest alloc] init];
 [request setEntity:entity];
 [request setRelationshipKeyPathsForPrefetching:[NSArray 
 arrayWithObjects:@topic,@view, nil]];

 results = [[self managedObjectContext] executeFetchRequest:request 
 error:error];
 if (results) {
        log4Debug(@Loaded %d topic nodes, [results count])
 }
 [request release];


 The log tells me id loaded my 2,000 topics.

 Then later, I do the following:

 // This is an array of topic nodes - the things that I have just fetched
 NSArray *allTopics = [map.rootTopicNode allDescendantTopicNodesIncludingSelf];

 NSSortDescriptor *sd = nil;
 if (floor(NSAppKitVersionNumber)  NSAppKitVersionNumber10_5) {
        sd = [NSSortDescriptor sortDescriptorWithKey:@view.zIndex 
 ascending:YES];
 } else {
        sd = [[[NSSortDescriptor alloc] initWithKey:@view.zIndex 
 ascending:YES] autorelease];
 }

 for (NMTopicNodeMO *node in [allTopics sortedArrayUsingDescriptors:[NSArray 
 arrayWithObject:sd]]) {
        Do stuff
 }


 But this was running really slowly, so I commented out the above couple of 
 lines, and did the following check:

 for (NMTopicNodeMO *ttn in allTopics) {
        if ([ttn isFault]) {
                log4Debug(@Node is a fault);
        }
        if ([ttn.view isFault]) {
                log4Debug(@View is fault);
        }
 }

 ...and it told me that the view was a fault for every topic node (but none of 
 the topic nodes were faults)!

 But I told it to pre-fetch the view relationship. Any ideas why it wouldn't 
 work?



 TIA

 Gideon








 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Core Data search optimizations

2011-07-14 Thread Heath Borders
I would use CLucene for this. It isn't as easy to use as CoreData (it
is written in C++, so you'll need some Objective-C++ as a shim at a
minimum), but it is powerful and VERY fast.

-Heath
From my iTouch4

On Jul 14, 2011, at 1:17 PM, Indragie Karunaratne cocoa...@indragie.com wrote:

 Hi guys,

 I'm working on a search feature in one of my Core Data based apps and I'm 
 trying to gather everyone's tips on search optimization to get it as fast as 
 I possibly can. The search needs to be fast enough that it can deliver 
 near-instantaneous results for database of 20,000+ objects.

 What I've done so far (as far as optimization goes)
 - Implemented the technique shown in WWDC 2010 session 137, creating a 
 keyword entity and creating a to-many relationship from my main object 
 entities to it. The keyword entity's 'name' attribute is indexed, and 
 keywords are created during the initial import procedure by splitting apart 
 relevant strings in the main entities and normalizing them (stripped of case 
 and diacritics)
 - Using = and  binary comparators instead of BEGINSWITH, etc. My predicate 
 format is: SUBQUERY(keywords, $keyword, ($keyword.name = $LB) AND 
 ($keyword.name  $UB)).@count != 0

 Where $LB is the lower bounds string and $UB is upper bounds. I create a 
 compound AND predicate using this format and the array of search terms.

 Right now, I'm executing a fetch once (when the user types the first letter) 
 using a fetch batch size of about 20, and then narrowing down the search 
 results using NSArray's -filteredArrayUsingPredicate method as they continue 
 typing. I also prefetch the keywords relationship because this is used to 
 filter. The part that takes up the most time, obviously, is the initial 
 fetch. There's a noticeable delay of ~1-2s on a library of around 15,000 
 objects. Time profiling shows that it is indeed the fetch that is causing the 
 delay:

 http://cl.ly/3a1b2022452M2V323f2H

 One other thing thats worth noting is that I have to fetch multiple entities 
 for the results. All of the entities have a ranking attribute, but I can't 
 fetch more than one at once so I'm forced to fetch them separately, combine 
 them into a single array, and then sort manually via 
 -sortedArrayUsingDescriptors.

 Any tips on how to speed this up would be greatly 
 appreciated.___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iOS: AVFoundation, AVAssetWriter and caching

2011-07-06 Thread Heath Borders
I'm pretty sure someone else on the list tried exactly that, and it didn't work.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Wed, Jul 6, 2011 at 11:40 AM, Steve Christensen puns...@mac.com wrote:
 With the caveat that I haven't actually tried it, would it make more sense to 
 be streaming the movie data to a local file, then specifying the URL/path to 
 the file in the initializer method of one of the movie player classes? If the 
 player can handle the case where not all the movie data is present then it 
 should just do the right thing. The benefit is that you can use the same 
 code to play the movie, no matter how much of it is local.


 On Jul 5, 2011, at 8:03 PM, John Michael Zorko wrote:

 I'm interested in caching a movie as I play it from the internet, so that 
 the next time the user asks for the movie, it can play it from the device 
 filesystem. I'm thinking capturing frames and audio and using an 
 AVAssetWriter like I would when recording from the camera, but i'm not sure 
 if this will work when recording from a playing asset. Would anyone 
 illuminate me as to whether this is possible, or if I need to explore other 
 ways of doing this (which would probably be a lot less cool and efficient 
 than doing it this way, alas)?

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] Will the be any problem in implementing an NSArray method using fast enumeration?

2011-06-30 Thread Heath Borders
You might also try HBCollections, a series of collections categories I wrote
that makes it easy to do stuff like this.

https://github.com/hborders/HBCollections

-Heath
On Jun 30, 2011 2:10 PM, Dave DeLong davedel...@me.com wrote:
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MFMailComposeViewController: referencing attached data in HTML body

2011-06-26 Thread Heath Borders
You could base64 your image data and use a data url to refer to it
within your HTML. Then, you wouldn't have to attach it.


-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Sun, Jun 26, 2011 at 6:14 PM, Pierre Fournier shir...@hotmail.com wrote:

 Hi,is there a way to reference the attached data within the HTML 
 body?[mailController addAttachmentData:pngDataFooter  mimeType:@image/png 
 fileName:@footer.png];[mailController setMessageBody:@htmlbodyimg 
 src=\footer.png\/body/html isHTML:TRUE];When running such code, I get 
 a blue question mark instead of the image, while the image is correctly 
 attached.I want to kind of compose an html email based of different images.   
                                        
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iOS: Automatically resizing subviews

2011-06-06 Thread Heath Borders
Make sure your subviews are small enough to fit inside your view initially.
I've had issues with resizing clipped subviews.

-Heath
On Jun 6, 2011 1:52 AM, Development developm...@fornextsoft.com wrote:
 I thought I understood how auto resizing worked but I don't


 According to the docs if I want to automatically resize all the subviews
of a view I need to set the View up with

 [self setAutoresizesSubviews:YES];
 self.contentMode =UIViewContentModeScaleToFill;

 No?

 I tried this but when I resize the view it's subview remains centered and
the same size.

 Inside of all the subviews I have done the following:
 [self setAutoresizingMask:UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight];

 Is there a step I'm missing?

 The problem is that the main view's subview rotates. And the whole thing
obviously can be resized.
 If I manually resize the rotated subview I'm doing it wrong because it
looses it's shape completely
 I was hoping I could use autoresizing to solve this issue but I can't get
it to work.___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Core Animation: performing a two-step animation

2011-06-01 Thread Heath Borders
Perform the second transform after the first animation completes in a
separate animation block.  You can start the second animation block
from the first animation block's completion block.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Wed, Jun 1, 2011 at 9:46 PM, Graham Cox graham@bigpond.com wrote:
 I'm new to Core Animation, so forgive me if I've missed something really 
 obvious.

 I want to perform a 2-step animation of a layer's -transform, so it appears 
 to expand then shrink back to end up slightly larger than it started out. I 
 can easily do a 1-step animation by using a scaling transform, but setting it 
 twice doesn't achieve the effect I want:



 myLayer.transform = CATransform3DMakeScale( 1.5, 1.5, 1.0 );
 myLayer.transform = CATransform3DMakeScale( 1.1, 1.1, 1.0 );

 Do I need to use a keyframe animation?

 --Graham


 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Fuzzy string matching

2011-05-31 Thread Heath Borders
CLucene might be a bit heavy, but it works great for me.

-Heath
From my iTouch4

On May 31, 2011, at 12:02 PM, Eric E. Dolecki edole...@gmail.com wrote:

 Thanks - I'm not sure that's going to be flexible enough for me or not, but
 I'll give it a go. Thanks again!


  Google Voice: (508) 656-0622
  Twitter: eric_dolecki  XBoxLive: edolecki  PSN: eric_dolecki
  http://blog.ericd.net



 On Tue, May 31, 2011 at 12:47 PM, Dave DeLong davedel...@me.com wrote:

 I've used this in the past with pretty good results:

 http://weblog.wanderingmango.com/?pg=2

 HTH,

 Dave

 Sent from my iPad

 On May 31, 2011, at 9:32 AM, Eric E. Dolecki edole...@gmail.com wrote:

 Wondering if anyone knows of or has an Obj-C Class that can provide
 levels
 of fuzzy string matching... looking for % match or something similar. I
 have
 something now but it's returning results that aren't nearly accurate
 enough
 for me to employ with confidence.

 Thank you,
 Eric



 Google Voice: (508) 656-0622
 Twitter: eric_dolecki  XBoxLive: edolecki  PSN: eric_dolecki
 http://blog.ericd.net
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com

 This email sent to davedel...@me.com

 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Threading synchronization: does a primitive exists?

2011-05-05 Thread Heath Borders
Try NSConditionLock. Its documentation should be pretty self-explanatory.



-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Thu, May 5, 2011 at 8:33 AM, eveningnick eveningnick
eveningn...@gmail.com wrote:
 Hello
 I have a thread A that spawns a thread B, and should stop, waiting
 before the thread B allows thread A to continue.

 In Windows, in a thread A, before spawning a thread B, i would create
 a synchronization Event primitive in the non signaled mode, the
 spawn a thread B, and call WaitForSingleObject(), waiting for thread B
 to switch the Event into the signaled mode, which would release
 the WaitForSingleObject() and allow the thread A to continue to
 operate.

 (WaitForSingleObject() freezes the thread, until the object that it is
 waiting for - e.g., an Event primitive - is switched into a
 signaled mode).

 In OS X i have no idea how to do that :S I guess it is impossible to
 do the same job using mutexes? Maybe some other primitives exist?

 I need this _only_ for debugging, it would greatly simplify my life. I
 am well aware that this is approach is deadlock-prone.

 Thanks for the response if i get one
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIGestureRecognizer in superview firing

2011-05-02 Thread Heath Borders
I've seen this behavior as well, and I solved it the same way you did.
 I hope there is a better way.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, May 2, 2011 at 3:15 AM, Roland King r...@rols.org wrote:
 I have a UIView subclass which has a number of UIButtons and UISliders on it, 
 it's a sort of control panel. I added UIPanGestureRecognizer to it with the 
 idea that if you stick your finger down outside one of the embedded controls, 
 you can move the window around. Wrote the handler for the gesture recognizer, 
 that worked.

 However I found that if I press one of the buttons, or try to drag one of the 
 sliders which are subviews of my view, the PanGestureRecognizer fires. That 
 completely breaks those controls as the sliders stop sliding and you cannot 
 drag yourself off the button to cancel the press, you just drag the view 
 around.

 I've re-read the UIGestureRecognizer documentation again twice and cannot 
 figure out why this is happening. Take the example of a touch going down on 
 the knob of one of the sliders, hitTest:withEvent correctly returns the 
 UISlider (I tested that) and so the touches should go to the slider directly 
 and not to its superview, my UIView subclass or its attached gesture 
 recognizer at all. I understand that gesture recognizers get touches before 
 their attached views, this from the Event Handling Guide For iOS

  Delivery of events initially follows the usual path: from operating system 
 to the application object to the window object representing the window in 
 which the touches are occurring. But before sending an event to the 
 hit-tested view, the window object sends it to the gesture recognizer 
 attached to that view or to any of that view’s subviews.

 In this case the hit-tested view was the UISlider so I would expect touches 
 to be sent to any gesture recognizers on that UISlider and its subviews and 
 then to the UISlider itself  but not to the UIView of which it's a subview 
 nor its attached gesture recognizer, the slider would work, the view wouldn't 
 try to pan.

 I did wonder if the UISlider didn't (for some strange reason) respond to 
 touchesBegan:withEvent: and thus the touch was bubbling back up to the 
 superview, my class, and being sent to the gesture recognizer there at the 
 same time, but apart from there being no documentation about such a flow, the 
 UISlider DOES respond to touchesBegan:withEvent:, so thats not it.

 I can only find documentation which talks about subviews of the hit-tested 
 view and their recognizers receiving touches, nothing can I find about 
 superviews, so this flow is puzzling.

 I'm going to use the PanGestureRecognizer delegate method 
 gestureRecognizer:shouldReceiveTouch: to stop this happening. Can someone 
 however explain which piece of documentation I've not read or have 
 misunderstood which explains why the PanGR on the superview of the hit-tested 
 view is getting touches at all?

 Thanks

 Roland


 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: viewWillDisappear not being called

2011-04-25 Thread Heath Borders
I've seen this behavior also, specifically on iOS 3.1 while using a
UIViewController inside a UINavigationController inside a
UITabBarController.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, Apr 25, 2011 at 9:59 PM, Jeffrey Walton noloa...@gmail.com wrote:
 Hi All,

 According to the documentation in the headers:

    // UIViewController.h
    // Called when the view is dismissed, covered or otherwise hidden.
    - (void)viewWillDisappear:(BOOL)animated;

 And Apple's documentation [1]:

    Notifies the view controller that its view is about to be dismissed,
    covered, or otherwise hidden from view.

 I'm not sure if I should be surprised or not, but viewWillDisappear
 does not appear to be called despite what the documentation claims.

 The view is part of a custom view controller (built with IB - nothing
 fancy) and presented modally. To duplicate, show a view modally and
 press the home button.

 Thanks in advance,
 Jeff

 [1] 
 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: viewWillDisappear not being called

2011-04-25 Thread Heath Borders
 It sure would have been helpful if viewWillDisappear was sent as
 documented. When the home button is pressed, and the home screen is
 presented, the view has clearly disappeared (no offense Alex).

I was seeing this when switching tabs, not when the home button was pressed.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Apr 26, 2011 at 12:19 AM, Jeffrey Walton noloa...@gmail.com wrote:
 On Mon, Apr 25, 2011 at 11:04 PM, Heath Borders heath.bord...@gmail.com 
 wrote:
 I've seen this behavior also, specifically on iOS 3.1 while using a
 UIViewController inside a UINavigationController inside a
 UITabBarController.
 YES - that is nearly my setup (iOS 4.3.2). I don't have the
 intermediate UINavigationController, but the view has an
 UINavigationBar.

 Any ideas on how to locate an arbitrary view controller? The following
 only locates the 5 associated with the Tab Bar, and not the top most
 PasswordPromptController (which was presented modally).

 It sure would have been helpful if viewWillDisappear was sent as
 documented. When the home button is pressed, and the home screen is
 presented, the view has clearly disappeared (no offense Alex).

 Jeff

 - (void)applicationWillResignActive:(UIApplication *)application
 {
  if(tabBarController.viewControllers != nil)
    [self clearPasswords:tabBarController.viewControllers];
 }

 - (void)clearPasswords:(NSArray *)viewsControllers
 {
  Class passwordPromptClass = [PasswordPromptController class];

  for (UIViewController * viewController in viewsControllers)
  {
    if ([viewController isKindOfClass:passwordPromptClass])
      [(PasswordPromptController *)viewController clearPassworAndPin];
  }
 }


 On Mon, Apr 25, 2011 at 9:59 PM, Jeffrey Walton noloa...@gmail.com wrote:
 Hi All,

 According to the documentation in the headers:

    // UIViewController.h
    // Called when the view is dismissed, covered or otherwise hidden.
    - (void)viewWillDisappear:(BOOL)animated;

 And Apple's documentation [1]:

    Notifies the view controller that its view is about to be dismissed,
    covered, or otherwise hidden from view.

 I'm not sure if I should be surprised or not, but viewWillDisappear
 does not appear to be called despite what the documentation claims.

 The view is part of a custom view controller (built with IB - nothing
 fancy) and presented modally. To duplicate, show a view modally and
 press the home button.

 Thanks in advance,
 Jeff

 [1] 
 http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
 [SNIP]

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Installing ipa from MobileSafari after deleting app requires restart

2011-04-22 Thread Heath Borders
I have an iPad1 running ios 4.3.2

I am distributing a beta version of my app with an ipa.  I have been
able to install from mobile safari without issue for a while.  A
couple of weeks ago, installing from MobileSafari would fail if I had
deleted the app before installing.  If I leave the app installed and
re-install, everything works fine.  If I delete my app, then restart
my iPad, then install my app from MobileSafari, everything works fine.

When I install from MobileSafari, my old App icon is still present in
SpringBoard while a new progress icon shows.  Then, the old icon is
removed when the progress icon completes.  This is different from an
App-Store upgrade where there is no old App icon present.

I created a small app to launch my app from a URL in case this was
just a SpringBoard issue.  It can launch my app when the App is
successfully installed, but fails to launch my app after a failed
install.

My console log is below:

Apr 22 17:09:53 testdevice kernel[0] Debug: launchd[77] Builtin
profile: MobileSafari (sandbox)
Apr 22 17:09:53 testdevice configd[26] Debug:
CaptiveNetworkSupport:UIAllowedNotifyCallback:70 uiallowed: true
Apr 22 17:10:32 testdevice configd[26] Debug:
CaptiveNetworkSupport:UIAllowedNotifyCallback:70 uiallowed: false
Apr 22 17:10:35 testdevice kernel[0] Debug: startEncoderGated
Adjusting tail padding to 20352, Last Requested Tail Padding 16384
Apr 22 17:11:16 testdevice installd[73] Error: libMobileGestalt
loadBasebandMobileEquipmentInfo: CommCenter error: 1:45
Apr 22 17:11:16 testdevice installd[73] Error: libMobileGestalt
copyInternationalMobileEquipmentIdentity: Could not get mobile
equipment info dictionary
Apr 22 17:11:19 testdevice installd[73] Error: libMobileGestalt
copyInternationalMobileEquipmentIdentity: Could not get mobile
equipment info dictionary

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Big Core Data, countForFetchRequest, and GCD

2011-03-29 Thread Heath Borders
For thread-safety's sake why don't you just create a separate
NSManagedObjectContext for your asyncTask?  They are cheap.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Mar 29, 2011 at 4:38 PM, Steve Mykytyn smyky...@gmail.com wrote:
 countForFetchRequest seems to bog down on really big collections of
 entities.  For approx 170K entities it takes around 10 seconds on an iPhone
 3GS to count them, which is a problem in a UITableView where you are trying
 to display a list of entities and associated counts.

 A GCD based solution, that queues up countForFetchRequest on a concurrent
 queue for each entity, and then updates the corresponding cell when
 finished, seems to work pretty well, although one or two big entity counts
 essentially bog down all the requests behind them.  Counts are cached so
 that countForFetchRequest is only called once for any entity.

 Code below, can anyone suggest any further optimization or different
 approaches that might be more effective?

 (I'm aware of the danger of multi-threading core data - this particular
 managed object context never changes and nothing is happening to it on other
 threads when this read is going on)

 - (void) countEntitiesNamed:(NSString *)entityName
 inContext:(NSManagedObjectContext *)context forIndexPath:(NSIndexPath
 *)indexPath {

 NSNumber *rowCountObject = [self.rowCountMD valueForKey:entityName];

 if (rowCountObject) return;

 //
 http://www.mikeash.com/pyblog/friday-qa-2009-08-28-intro-to-grand-central-dispatch-part-i-basics-and-dispatch-queues.html

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
 0), ^{

  NSEntityDescription *ed;
  NSFetchRequest  *frq;

  frq = [[[NSFetchRequest alloc] init] autorelease];
  ed = [NSEntityDescription entityForName:entityName
 inManagedObjectContext:context];
  [frq setEntity:ed];
  NSDate *startDate = [NSDate date];
  NSUInteger rowCount = [context countForFetchRequest:frq error:nil];
  NSTimeInterval timeInterval = -[startDate timeIntervalSinceNow];
  DLog(@%0.2lf seconds for %d %@ ,timeInterval,rowCount,entityName);

      dispatch_async(dispatch_get_main_queue(), ^{
  [rowCountMD setValue:[NSNumber numberWithInteger:rowCount]
 forKey:entityName];
  UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  cell.detailTextLabel.text = [NSString stringWithFormat:@%@ objects,
      [NSNumberFormatter localizedStringFromNumber:[NSNumber
 numberWithInteger:rowCount]
       numberStyle:NSNumberFormatterDecimalStyle]];

       });
  });


 }
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-22 Thread Heath Borders
Your code worked!  Thanks!  The main difference between our snippets
was that you added the MPMoviePlayerController's view directly to the
UIViewController's view rather than putting it in a holder view (which
I doubt would matter) and that you aren't using the embedded controls.
 I'll post back when I figure out what went wrong.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, Mar 21, 2011 at 11:50 PM, Matt Neuburg m...@tidbits.com wrote:
 On Mon, 21 Mar 2011 22:59:04 -0500, Heath Borders heath.bord...@gmail.com 
 said:
That's exactly what I did.  I have a brand new project with just a
ViewController with 3 views

[SNIP ridiculous quantities of code]

 I can't read that. And it isn't what I suggested you do. I said make a 
 *minimal* project. Enough to prove to yourself that setting the contentURL 
 works. And no more than that! Here's my code; this is what I mean when I say 
 minimal and simple and stuff like that:

 - (void)viewDidLoad {
    [super viewDidLoad];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
    player.shouldAutoplay = NO;
    player.controlStyle = MPMovieControlStyleNone;
    [player.view setFrame: CGRectMake(0,0,200,150)];
    [self.view addSubview: player.view];
    self.thePlayer = player;
    [player release];

 }
 - (IBAction)play1:(id)sender { // button 1
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
        URLForResource:@blend1 withExtension:@mp4]];
    [self.thePlayer play];
 }

 - (IBAction)play2:(id)sender { // button 2
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
         URLForResource:@xbox withExtension:@mp4]];
    [self.thePlayer play];
 }

 That's all. It works. So then you build up from there towards what you 
 *really* want to do. When it stops working, that's when you broke it. m.


 --
 matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
 A fool + a tool + an autorelease pool = cool!
 Programming iOS 4!
 http://www.apeth.net/matt/default.html#iosbook
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-22 Thread Heath Borders
I was able to replicate my issue.  In my original code, I was only
allowing the movie to be played with the embedded controls.  When I
set the contentURL a second time, my embedded controls were not
showing, so I couldn't play the movie again.  As I mentioned
previously, Matt's code worked great.  However, I can replicate my
issue by removing line 4 below.

1 - (IBAction)play1:(id)sender { // button 1
2   [self.thePlayer setContentURL: [[NSBundle mainBundle]
3URLForResource:@blend1 withExtension:@mp4]];
4[self.thePlayer play];
5 }

I only want to control the movie from the embedded controls, so I
don't want to programmatically play it.  In the MPMediaPlayback
protocol, there is a prepareToPlay method, which must always be called
before the movie starts playing, and which is called if needed by
play.

So, replacing line 4 with

[self.thePlayer prepareToPlay];

makes my code work.

Thanks again for your help, Matt!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Mar 22, 2011 at 8:30 AM, Heath Borders heath.bord...@gmail.com wrote:
 Your code worked!  Thanks!  The main difference between our snippets
 was that you added the MPMoviePlayerController's view directly to the
 UIViewController's view rather than putting it in a holder view (which
 I doubt would matter) and that you aren't using the embedded controls.
  I'll post back when I figure out what went wrong.

 -Heath Borders
 heath.bord...@gmail.com
 Twitter: heathborders
 http://heath-tech.blogspot.com



 On Mon, Mar 21, 2011 at 11:50 PM, Matt Neuburg m...@tidbits.com wrote:
 On Mon, 21 Mar 2011 22:59:04 -0500, Heath Borders heath.bord...@gmail.com 
 said:
That's exactly what I did.  I have a brand new project with just a
ViewController with 3 views

[SNIP ridiculous quantities of code]

 I can't read that. And it isn't what I suggested you do. I said make a 
 *minimal* project. Enough to prove to yourself that setting the contentURL 
 works. And no more than that! Here's my code; this is what I mean when I say 
 minimal and simple and stuff like that:

 - (void)viewDidLoad {
    [super viewDidLoad];
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init];
    player.shouldAutoplay = NO;
    player.controlStyle = MPMovieControlStyleNone;
    [player.view setFrame: CGRectMake(0,0,200,150)];
    [self.view addSubview: player.view];
    self.thePlayer = player;
    [player release];

 }
 - (IBAction)play1:(id)sender { // button 1
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
        URLForResource:@blend1 withExtension:@mp4]];
    [self.thePlayer play];
 }

 - (IBAction)play2:(id)sender { // button 2
    [self.thePlayer setContentURL: [[NSBundle mainBundle]
         URLForResource:@xbox withExtension:@mp4]];
    [self.thePlayer play];
 }

 That's all. It works. So then you build up from there towards what you 
 *really* want to do. When it stops working, that's when you broke it. m.


 --
 matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
 A fool + a tool + an autorelease pool = cool!
 Programming iOS 4!
 http://www.apeth.net/matt/default.html#iosbook

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSOperation with unit test

2011-03-22 Thread Heath Borders
Your NSOperation is probably running on a background thread managed by
the NSOperationQueue.  Your test needs to wait until the
NSOperationQueue has processed all its tasks.


-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Mar 22, 2011 at 10:35 PM, Shane
software.research.developm...@gmail.com wrote:
 Hi,

 I am trying to write a unit test for a class that inherits from
 NSOperation. And I've implemented this class just as I did in my
 application (which works) and the test case is running, but when the
 'addOperation:myClass' on the NSOperationQueue is called within the
 test method, I don't see that my NSOperation class is being executed.

 Is there something different about running NSOperations within a unit test?
 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com

 This email sent to heath.bord...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MPMoviePlayerController setContentURL twice

2011-03-21 Thread Heath Borders
I create an embedded MPMoviePlayerController thusly inside my loadView method:

self.moviePlayerController = [[[MPMoviePlayerController alloc] init]
autorelease];

// add to view, setup moviePlayerController's view frame, etc

And I can later load a movie the user chooses thusly:

NSURL *fileUrl = ...
self.moviePlayerController.contentURL = fileUrl;

and everything works great.


However, if I set the contentURL again:

NSURL *fileUrl2 = ...
self.moviePlayerController.contentURL = fileUrl2;

This does not work, even if fileUrl2 == fileUrl1.

When I change the contentURL, I get the following playbackState and loadState:

After first setContentURL:
loadState == playable | playthroughOK
playbackState == playing

After my second setContentURL:
playbackState == stopped
loadState == unknown

I can of course create a new MPMoviePlayerController for every movie,
but I want to make sure this issue isn't indicative of a larger
problem.

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: MPMoviePlayerController setContentURL twice

2011-03-21 Thread Heath Borders
 forState:UIControlStateNormal];

[self.view addSubview:loadAudioButton];

UIButton *loadVideoButton = [UIButton 
buttonWithType:UIButtonTypeRoundedRect];
loadVideoButton.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin;
loadVideoButton.frame = CGRectMake(CGRectGetMaxX(loadAudioButton.frame),
   
CGRectGetMaxY(self.moviePlayerHolderView.frame),
   
CGRectGetWidth(self.view.bounds) / 2,
   50);
[loadVideoButton addTarget:self

action:@selector(loadBigVideoFromFile)
  forControlEvents:UIControlEventTouchUpInside];
[loadVideoButton setTitle:@Load Video
 forState:UIControlStateNormal];

[self.view addSubview:loadVideoButton];
}

- (void)viewDidUnload {
self.moviePlayerHolderView = nil;
self.moviePlayerController = nil;

[[NSNotificationCenter defaultCenter] removeObserver:self];

[super viewDidUnload];
}

- 
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

#pragma mark -
#pragma mark private API

- (void)loadBigAudioFromFile {
NSURL *fileUrl = [[NSBundle mainBundle] URLForResource:@heath

 withExtension:@mov];

[self loadAssetFromFileUrl:fileUrl];
}

- (void)loadBigVideoFromFile {
NSURL *fileUrl = [[NSBundle mainBundle] URLForResource:@heath2

 withExtension:@mov];

[self loadAssetFromFileUrl:fileUrl];
}

- (void)loadAssetFromFileUrl: (NSURL *) fileUrl {   
[self.moviePlayerController stop];
self.moviePlayerController.contentURL = fileUrl;
NSLog(@after setContentURL to %@: %@, fileUrl,
self.moviePlayerController.contentURL);
}

- (void)moviePlayerPlaybackStateDidChange {
switch (self.moviePlayerController.playbackState) {
case MPMoviePlaybackStateStopped:
NSLog(@stopped);
break;
case MPMoviePlaybackStatePlaying:
NSLog(@playing);
break;
case MPMoviePlaybackStatePaused:
NSLog(@paused);
break;
case MPMoviePlaybackStateInterrupted:
NSLog(@interrupted);
break;
case MPMoviePlaybackStateSeekingForward:
NSLog(@seeking forward);
break;
case MPMoviePlaybackStateSeekingBackward:
NSLog(@seeking backward);
break;
default:
NSLog(@Unexpected playback state);
break;
}
}

- (void)moviePlayerLoadStateDidChange {
MPMovieLoadState loadState = self.moviePlayerController.loadState;

if (loadState == MPMovieLoadStateUnknown) {
NSLog(@unknown);
} else {
MPMovieLoadState loadStates[3] = {
MPMovieLoadStatePlayable, MPMovieLoadStatePlaythroughOK,
MPMovieLoadStateStalled
};
for (int i=0; i  3; i++) {
switch (loadState  loadStates[i]) {
case MPMovieLoadStatePlayable:
NSLog(@playable);
break;
case MPMovieLoadStatePlaythroughOK:
NSLog(@playthroughOK);
break;
case MPMovieLoadStateStalled:
NSLog(@stalled);
break;
default:
break;
}
}
}

NSLog(@ContentURL: %@, self.moviePlayerController.contentURL);
}

@end


-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Mon, Mar 21, 2011 at 10:47 PM, Matt Neuburg m...@tidbits.com wrote:
 On Mon, 21 Mar 2011 16:04:52 -0500, Heath Borders heath.bord...@gmail.com 
 said:
I create an embedded MPMoviePlayerController thusly inside my loadView method:

self.moviePlayerController = [[[MPMoviePlayerController alloc] init]
autorelease];

// add to view, setup moviePlayerController's view frame, etc

Re: XML Namespace Definitions on Non-Root Elements

2011-03-07 Thread Heath Borders
That worked!

I actually changed it to:

nodesForXPath:@/root/*[name() = \example:foo\]

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Sat, Mar 5, 2011 at 2:27 PM, Matt Neuburg m...@tidbits.com wrote:
 On Fri, 04 Mar 2011 14:25:06 -0600, Heath Borders heath.bord...@gmail.com 
 said:
I'm trying to parse a document with a namespace declared on a non-root 
element:

rootexample:foo xmlns:example=http://example.com/foo;This is an
exemplary foo!/example:foo/root

I can read this xml into an NSXMLDocument just fine, but the following
XPath query on root returns a non-nil, but empty NSArray:

NSXMLNode *rootNode = ...// create my root node somehow
NSArray *exampleFooElements = [rootNode
nodesForXPath:@/root/example:foo error:nil];
// exampleFooElements != nil  [exampleFooElements count] == 0

However, if I add the namespace declaration to the root element,
everything is fine:

root xmlns:example=http://example.com/foo;example:fooThis is an
exemplary foo!/example:foo/root

NSXMLNode *rootNode = ...// create my root node somehow
NSArray *exampleFooElements = [rootNode
nodesForXPath:@/root/example:foo error:nil];
// exampleFooElements != nil  [exampleFooElements count] == 1

I can do this change programmatically, but I'd rather not have to
modify the document.  This namespace usage should be legal.  Am I
doing something wrong?

 It's no use just saying example:; you have to have a way to tell it what 
 example: *is* - i.e. you have to bind the namespace - and you don't have a 
 way to do that from here. One option is to bypass the namespace altogether:

  nodesForXPath:@//*[local-name()='foo']

 m.


 --
 matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
 A fool + a tool + an autorelease pool = cool!
 Programming iOS 4!
 http://www.apeth.net/matt/default.html#iosbook
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Proper way to construct an Attribute NSXMLNode so that its prefix is included in its XMLString

2011-03-07 Thread Heath Borders
I have the following NSXMLDocument:

document xmlns=http://example.com/document;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
/document

I want to add an xsi:schemaLocation to the document so that I can validate it.

The documentation says:

attributeWithName:URI:stringValue:
Returns an NSXMLNode object representing an attribute node with a
given qualified name and string.

+ (id)attributeWithName:(NSString *)name URI:(NSString *)URI
stringValue:(NSString *)value
Parameters
name
A string that is the name of an attribute.
URI
A URI (Universal Resource Identifier) that qualifies name.
value
A string that is the value of the attribute.
Return Value
An NSXMLNode object of kind NSXMLAttributeKind or nil if the object
couldn't be created.

Discussion
For example, in the attribute “bst:id=`12345’”, “bst” is the name
qualifier (derived from the URI), “id” is the attribute name, and
“12345” is the attribute value.

Thus, I do the following:

NSXMLElement rootXmlElement = ...
NSXMLNode *schemaLocationAttributeXmlNode =
  [NSXMLNode attributeWithName:@schemaLocation URI:@xsi
stringValue:@http://example.com/document document.xsd];

[rootXmlElement addAttribute:schemaLocationAttributeXmlNode];

However, this yields the following xml:

document xmlns=http://example.com/document;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
schemaLocation=@http://example.com/document document.xsd
/document

Notice that there should be an xsi prefix on the schemaLocation attribute.

and if I call try to get the attribute from the rootXmlElement, I get nothing:

[rootXmlElement attributeForLocalName:@schemaLocation
URI:@http://www.w3.org/2001/XMLSchema-instance;] == nil


Since this didn't work, I tried using the namespace URI instead of the
prefix when creating the attribute:

NSXMLElement rootXmlElement = ...
NSXMLNode *schemaLocationAttributeXmlNode =
  [NSXMLNode attributeWithName:@schemaLocation
URI:@http://www.w3.org/2001/XMLSchema-instance;
stringValue:@http://example.com/document document.xsd];

[rootXmlElement addAttribute:schemaLocationAttributeXmlNode];

This still yielded bad xml:

document xmlns=http://example.com/document;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
schemaLocation=@http://example.com/document document.xsd
/document

However, this time I can at least get the attribute from my rootXmlElement:

[rootXmlElement attributeForLocalName:@schemaLocation
URI:@http://www.w3.org/2001/XMLSchema-instance;] != nil // closer!


So, now, I tried specifying the prefix in the attribute name when
creating the attribute:

NSXMLElement rootXmlElement = ...
NSXMLNode *schemaLocationAttributeXmlNode =
  [NSXMLNode attributeWithName:@xsi:schemaLocation
URI:@http://www.w3.org/2001/XMLSchema-instance;
stringValue:@http://example.com/document document.xsd];

[rootXmlElement addAttribute:schemaLocationAttributeXmlNode];

Success!  I got good xml:

document xmlns=http://example.com/document;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=@http://example.com/document document.xsd
/document

This doesn't seem consistent with the documentation.  Am I hacking here?

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Validating NSXMLDocument with xml:space attributes

2011-03-07 Thread Heath Borders
I have the following document:

root xmlns=http://example.com/root;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://example.com/root root.xsdfoo
xml:space=preserve there is leading and trailing whitespace here
/foo/root

With the following XSD:

?xml version=1.0 encoding=utf-8?
xs:schema elementFormDefault=qualified
xmlns:xs=http://www.w3.org/2001/XMLSchema;
targetNamespace=http://example.com/root;
xmlns=http://example.com/root;
xs:import namespace=http://www.w3.org/XML/1998/namespace;
schemaLocation=http://www.w3.org/2001/03/xml.xsd; /

!-- Complex types describing all parts of the document --
xs:complexType name=fooType
xs:simpleContent
xs:extension base=xs:string
xs:attribute ref=xml:space fixed=preserve 
/
/xs:extension
/xs:simpleContent
/xs:complexType

!-- The actual schema itself --
xs:element name=root
xs:complexType
xs:sequence
xs:element name=foo type=fooType
minOccurs=0 maxOccurs=unbounded /
/xs:sequence
/xs:complexType
/xs:element
/xs:schema


When I try to validate by reading in my document and then calling:

NSXMLDocument *document = ...
NSError *error = nil;
[document validateAndReturnError:error];

I always get the following errors:

Element '{http://example.com}foo', attribute 'space': The attribute
'space' is not allowed.
Element '{http://example.com}foo', attribute 'space': The attribute
'space' is not allowed.
Element '{http://example.com}foo', attribute 'space': The attribute
'space' is not allowed.


-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSXMLElement children doesn't return whitespace text nodes

2011-03-04 Thread Heath Borders
That worked!

Embarrassingly, I looked at the documentation for NSXMLDocumentTidyXML
and found my answer, as well:

Changes malformed XML into valid XML during processing of the document.
It also eliminates “pretty-printing” formatting, such as leading tab
characters. However, it respects the xmlns:space=preserve attribute.
(Input)
Available in Mac OS X v10.4 and later.
Declared in NSXMLNodeOptions.h.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Thu, Mar 3, 2011 at 10:33 PM, Gideon King gid...@novamind.com wrote:
 I recall that I had problems with that too, and IIRC, the 
 NSXMLNodePreserveWhitespace didn't seem to work, but right now I have 
 xml:space=preserve in the XML and parse it with just the 
 NSXMLDocumentTidyXML option, and that works. I believe I just went through 
 all the combinations and permutations until I found that magic combination, 
 and have just stuck with it.

 HTH

 Regards

 Gideon
 On 04/03/2011, at 3:02 AM, Heath Borders wrote:

 I have the following xml:

 rootfooA foo./foo barA bar./bar/root

 Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?

 I've also tried changing my document thusly:

 root xml:space=preservefooA foo./foo barA bar./bar/root

 I specify

 NSXMLNodePreserveWhitespace

 as my option to NSXMLDocument's

 initWithXMLString:options:error:

 selector.

 Thanks!



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


XML Namespace Definitions on Non-Root Elements

2011-03-04 Thread Heath Borders
I'm trying to parse a document with a namespace declared on a non-root element:

rootexample:foo xmlns:example=http://example.com/foo;This is an
exemplary foo!/example:foo/root

I can read this xml into an NSXMLDocument just fine, but the following
XPath query on root returns a non-nil, but empty NSArray:

NSXMLNode *rootNode = ...// create my root node somehow
NSArray *exampleFooElements = [rootNode
nodesForXPath:@/root/example:foo error:nil];
// exampleFooElements != nil  [exampleFooElements count] == 0

However, if I add the namespace declaration to the root element,
everything is fine:

root xmlns:example=http://example.com/foo;example:fooThis is an
exemplary foo!/example:foo/root

NSXMLNode *rootNode = ...// create my root node somehow
NSArray *exampleFooElements = [rootNode
nodesForXPath:@/root/example:foo error:nil];
// exampleFooElements != nil  [exampleFooElements count] == 1

I can do this change programmatically, but I'd rather not have to
modify the document.  This namespace usage should be legal.  Am I
doing something wrong?

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSXMLElement children doesn't return whitespace text nodes

2011-03-04 Thread Heath Borders
From the Tree-Based XML Programming Guide:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSXML_Concepts/Articles/CreatingXMLDoc.html#//apple_ref/doc/uid/TP40001255-BCIGHBDI

Preservation. The enum constants beginning with NSXMLNodePreserve
support document fidelity. They allow you to ensure that aspects of
the string XML input—for instance, quoting style of attribute values,
CDATA sections, attribute and namespace order—remain the same when XML
text is written out from the NSXMLDocument object. If you do not
specify a preservation option for an aspect, NSXMLDocument handles it
in a predetermined manner. For example, when NSXMLDocument reads in
and parses an XML document, it normally strips white-space characters
used in formatting (including tabs and carriage returns); however, if
you specify NSXMLNodePreserveWhitespace these characters are kept
hidden in the internal representation of the XML document. (“Hidden”
means the white-space characters are retained for the output of the
document, but are not visible within the tree representation.) Note
that white space in text nodes is always preserved, and is not
affected by the NSXMLNodePreserveWhitespace option.

Notice the last sentence:

Note that white space in text nodes is always preserved, and is not
affected by the NSXMLNodePreserveWhitespace option.

If my text node has non-whitespace in it, it gets recognized as a text
node, and whitespace is preserved in the stringValue:

rootfooA foo./foomyText a space on either side /myTextbarA
bar./bar/root

NSXMLElement *myTextElement = ... // get myText element somehow

[myTextElement stringValue]; // returns  a space on either side 

However:

rootfooA foo./foomyText /myTextbarA bar./bar/root

NSXMLElement *myTextElement = ... // get myText element somehow

[myTextElement stringValue]; // returns  (empty)

This seems inconsistent with

Note that white space in text nodes is always preserved, and is not
affected by the NSXMLNodePreserveWhitespace option.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Fri, Mar 4, 2011 at 9:40 AM, Heath Borders heath.bord...@gmail.com wrote:
 That worked!

 Embarrassingly, I looked at the documentation for NSXMLDocumentTidyXML
 and found my answer, as well:

 Changes malformed XML into valid XML during processing of the document.
 It also eliminates “pretty-printing” formatting, such as leading tab
 characters. However, it respects the xmlns:space=preserve attribute.
 (Input)
 Available in Mac OS X v10.4 and later.
 Declared in NSXMLNodeOptions.h.

 -Heath Borders
 heath.bord...@gmail.com
 Twitter: heathborders
 http://heath-tech.blogspot.com



 On Thu, Mar 3, 2011 at 10:33 PM, Gideon King gid...@novamind.com wrote:
 I recall that I had problems with that too, and IIRC, the 
 NSXMLNodePreserveWhitespace didn't seem to work, but right now I have 
 xml:space=preserve in the XML and parse it with just the 
 NSXMLDocumentTidyXML option, and that works. I believe I just went through 
 all the combinations and permutations until I found that magic combination, 
 and have just stuck with it.

 HTH

 Regards

 Gideon
 On 04/03/2011, at 3:02 AM, Heath Borders wrote:

 I have the following xml:

 rootfooA foo./foo barA bar./bar/root

 Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?

 I've also tried changing my document thusly:

 root xml:space=preservefooA foo./foo barA bar./bar/root

 I specify

 NSXMLNodePreserveWhitespace

 as my option to NSXMLDocument's

 initWithXMLString:options:error:

 selector.

 Thanks!




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSXMLElement children doesn't return whitespace text nodes

2011-03-03 Thread Heath Borders
I have the following xml:

rootfooA foo./foo barA bar./bar/root

Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?

I've also tried changing my document thusly:

root xml:space=preservefooA foo./foo barA bar./bar/root

I specify

NSXMLNodePreserveWhitespace

as my option to NSXMLDocument's

initWithXMLString:options:error:

selector.

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com