Re: Core Data: Insert, Fetch, Re-Fetch. Same Object?

2010-02-11 Thread Alexander Spohr

Am 11.02.2010 um 04:07 schrieb Jerry Krinock:

 
 On 2010 Feb 10, at 18:05, Jens Alfke wrote:
 
 I've always wondered if I insert a managed object, then later fetch it 
 repeatedly from the same managed object context, do I get the same object 
 every time?
 
 Yes, basically. There is only going to be one in-memory object at a time 
 that represents the same managed object.
 
 It certainly seems to be sensible, but I just wish someone could find such 
 documentation.  I can't.

Every NSManagedObjectContext holds its own but unique copy of your object.


 In the last few minutes here, I improved my demo to test an sqlite store as 
 well as an in-memory store, and also I setStalenessInterval to 0 and threw in 
 some -refreshObject:mergeChanges:NO and more saves.  The only difference I 
 found was that, while the in-memory store fetches the same object that you 
 inserted, the sqlite store does not, although subsequent fetches return the 
 same object.

This is because the object in the sql-store needs a primary key. As long as it 
was not saved it has a temporary key only. When saved it gets a persistent key.
After that it is identifiable by this and therefore you get alwas the same 
object back.

I would have thought that your inserted object gets the persistent key set and 
will therefore be the same object as the fetched ones. But I did not check your 
code for a misconfiguration.

 Can anyone guarantee this?
 I would imagine that, even though it's not documented, Apple must realize 
 that if they were ever to change this behavior, it would probably break alot 
 of apps which have been relying on it without the designers realizing this.  
 Would Apple ever ever do anything like that?

No, you will always get the same object. Because this was why CoreData and EOF 
where made for. Exactly this.

atze

 Jerry
 
 
 REVISED CONSOLE OUTPUT:
 
 Using sqlite store at /Users/jk/Desktop/FooTest.sqlite
   Inserted: Foo 0x30022c0 name=Murphy ivar=BeenInserted
  First Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched
 Second Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched
  Delay Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched saved=1
  Delay Fetched: Foo 0x3006120 name=Murphy ivar=BeenFetched saved=1
 
 Using in-memory store
   Inserted: Foo 0x300c1a0 name=Murphy ivar=BeenFetched
  First Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched
 Second Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched
  Delay Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched saved=1
  Delay Fetched: Foo 0x300c1a0 name=Murphy ivar=BeenFetched saved=1
 
 
 REVISED DEMO PROJECT:
 
 #import Foundation/Foundation.h
 #import CoreData/CoreData.h
 
 @interface Foo : NSManagedObject
 {
NSString* m_ivar ;
 }
 
 @property (copy) NSString* ivar ;
 
 @end
 
 @implementation Foo
 
 @synthesize ivar = m_ivar ;
 
 - (void)dealloc {
[m_ivar release] ;
 
[super dealloc] ;
 }
 
 - (NSString*)description {
return [NSString stringWithFormat:
@Foo %p name=%@ ivar=%@,
self,
[self valueForKey:@name],
[self ivar]] ;
 }
 
 @end
 
 
 // Note: This function returns a retained, not autoreleased, instance.
 NSManagedObjectModel *getStaticManagedObjectModel() {
static NSManagedObjectModel *mom = nil;
 
if (mom != nil) {
return mom;
}
 
mom = [[NSManagedObjectModel alloc] init];
 
NSEntityDescription *fooEntity = [[NSEntityDescription alloc] init];
[fooEntity setName:@Foo];
[fooEntity setManagedObjectClassName:@Foo];
[mom setEntities:[NSArray arrayWithObject:fooEntity]];
 
NSMutableArray* properties = [[NSMutableArray alloc] init] ;
NSAttributeDescription *attributeDescription;
 
// Add an attribute.  (Copy this section to add more attributes.)
attributeDescription = [[NSAttributeDescription alloc] init];
[attributeDescription setName:@name];
[attributeDescription setAttributeType:NSStringAttributeType];
[attributeDescription setOptional:YES];
[properties addObject:attributeDescription] ;
[attributeDescription release] ;
 
[fooEntity setProperties:properties];
[properties release] ;
 
[fooEntity release] ;
 
return mom;
 }
 
 // Note: This function returns a retained, not autoreleased, instance.
 NSManagedObjectContext *getStaticManagedObjectContext() {
 
static NSManagedObjectContext *moc = nil;
 
if (moc != nil) {
return moc;
}
 
moc = [[NSManagedObjectContext alloc] init];
 
NSPersistentStoreCoordinator *coordinator =
[[NSPersistentStoreCoordinator alloc]
 initWithManagedObjectModel:getStaticManagedObjectModel()];
[moc setPersistentStoreCoordinator: coordinator];
[coordinator release] ;
 
NSError *error;
NSPersistentStore *newStore ;
 #if 0
NSLog(@Using in-memory store) ;
newStore = [coordinator addPersistentStoreWithType:NSInMemoryStoreType
 configuration:nil
  

Re: [iPhone 3.1] NSInvocation on main thread?

2010-02-11 Thread Peter Blazejewicz
Hi John,
NSInvocation can be invoked on main thread as any NSObject subclass
simply by performing selector on itself on main thread,
However I think you're looking for custom additions similar to that
one blogged here (Dave Dribin's blog):
http://www.dribin.org/dave/blog/archives/2008/05/22/invoke_on_main_thread/

hth,
regards,
Peter

On Thu, Feb 11, 2010 at 8:09 AM, John Michael Zorko jmzo...@mac.com wrote:

 Hello, all ...

 I'm using NSInvocation so I can pass multiple arguments to delegate methods. 
 However, I also want these delegate methods to get called on the main thread. 
 Is there a way that I can use NSInvocation to call the method it wraps on the 
 main thread, like performSelectorOnMainThread?
___

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: [ANN] CocoaHeads Paris group meeting

2010-02-11 Thread Guillaume Cerquant

On 4 févr. 2010, at 10:50, Guillaume Cerquant wrote:

 Hi,
 
 This message is about the CocoaHeads Paris group:
 Our 10th meeting is planned for next week: thursday, 11th of february 2010.
 
 Session starts at 7pm inside the school IESA: 5, rue Saint-Augustin - 75002 
 Paris - France.
 The sessions will be about localization and bindings.
 
 Access is open to everyone and free.
 More details at: http://cocoaheads.org/fr/Paris/
 
 We meet every 2nd thursday of the month, same place.
 
 Thank you for your attention. You may now go back to Xcode :)


The place for this meeting has changed.

Please come to:
Ecole IESA
5, avenue de l'Opéra 
75001 Paris 

Same time (7pm).

See you tonight

-- 
Guillaume___

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: -[NSBundle preferredLocalizations]

2010-02-11 Thread Kai Brüning
Done: rdar://7637393
Kai


 
 On Feb 10, 2010, at 5:52 AM, Kai Brüning wrote:
 
 Could somebody with insight confirm whether this is a documentation bug?
 
 This is indeed an error in the documentation.  Please file a bug against the 
 documentation with the information you have provided.
 
 Douglas Davidson

___

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


NSAttributtedString initWithHTML skip styles

2010-02-11 Thread Gustavo Pizano
Hello, 

Im creating an HTMLString form a NSTextView like this:

NSArray * exclude = [NSArray arrayWithObjects:@doctype, @html, @head, 
@body,@xml,nil];
NSDictionary * htmlAtt = [NSDictionary 
dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,NSDocumentTypeDocumentAttribute,exclude,NSExcludedElementsDocumentAttribute,nil];
NSError * error; 
NSData * htmlData = [_mString dataFromRange:NSMakeRange(0, [_mString 
length]) documentAttributes:htmlAtt error:error];
NSString  * sdat = [[[NSString alloc] initWithData:htmlData 
encoding:NSUTF8StringEncoding] autorelease];

andIts being created perfectly.

now I need to do the inverse operation.. and Im doping the follwoing:

NSDictionary * attributesOfString;
NSArray * exclude = [NSArray arrayWithObjects:@doctype, @html, @head, 
@body,@xml,nil];
NSDictionary * htmlAtt = [NSDictionary 
dictionaryWithObjectsAndKeys:NSHTMLTextDocumentType,NSDocumentTypeDocumentOption,exclude,NSExcludedElementsDocumentAttribute,nil];
   
NSAttributedString * valueString =  [[NSAttributedString alloc] 
initWithHTML:[[specificComponent objectValue] 
dataUsingEncoding:NSUTF8StringEncoding]

 options:htmlAtt 
documentAttributes:attributesOfString];
[(XWSDefaultComponentView *)[component view] 
setTypingAttributes:attributesOfString];
[(XWSDefaultComponentView *)[component view] setString:[valueString string]];


But when I display the NSTextViuew all the string its without any style, no 
bold, no colors no nothing..

Any ideas what might I being doing wrong?

Thanks a lot.

Gustavo

___

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: NSAttributtedString initWithHTML skip styles

2010-02-11 Thread Graham Cox

On 11/02/2010, at 9:45 PM, Gustavo Pizano wrote:

 [(XWSDefaultComponentView *)[component view] setString:[valueString string]];
 
 
 But when I display the NSTextViuew all the string its without any style, no 
 bold, no colors no nothing..
 
 Any ideas what might I being doing wrong?


Sure. You're calling -setString: on the text view with just the string part of 
the attributed string you've carefully built. So all the attributes are getting 
discarded.

You need to do something like this:

[textView setRichText:YES];
[[textView textStorage] setAttributedString:valueString];

--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/archive%40mail-archive.com

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


iPhone: badge icon for a button in toolbar

2010-02-11 Thread Eric E. Dolecki
I know about placing a badge on the homescreen application icon, but is
there a way to set this up for a button in a toolbar... or do I just use my
own UIView to do the same thing and float it over the toolbar?

Eric
___

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: iPhone: badge icon for a button in toolbar

2010-02-11 Thread Mark Woollard
See UITabBarItem's badgeValue property.

Regards
Mark

On 11 Feb 2010, at 13:40, Eric E. Dolecki wrote:

 I know about placing a badge on the homescreen application icon, but is
 there a way to set this up for a button in a toolbar... or do I just use my
 own UIView to do the same thing and float it over the toolbar?
 
 Eric
 ___
 
 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/mark.woollard%40mac.com
 
 This email sent to mark.wooll...@mac.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: iPhone: badge icon for a button in toolbar

2010-02-11 Thread Eric E. Dolecki
Awesome  - thank you!

Now I am looking at how to access a certain UIBarButtonItem so I can set
it's badge.

In my app delegate I have a UITabBarController. In IB I can't seem to create
an IBOutlet and wire the button I want up so I can set it's badge string.
When I attempt to wire it up from File's Owner (MainWindow.xib), I only have
the option Outlets -delegate.

- (void)applicationDidFinishLaunching:(UIApplication *)application {

*// Add the tab bar controller's current view as a subview of the window
*

[window addSubview:tabBarController.view];


How do I access the button I want from the appDelegate?



On Thu, Feb 11, 2010 at 8:46 AM, Mark Woollard mark.wooll...@mac.comwrote:

 See UITabBarItem's badgeValue property.

 Regards
 Mark

 On 11 Feb 2010, at 13:40, Eric E. Dolecki wrote:

  I know about placing a badge on the homescreen application icon, but is
  there a way to set this up for a button in a toolbar... or do I just use
 my
  own UIView to do the same thing and float it over the toolbar?
 
  Eric
  ___
 
  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/mark.woollard%40mac.com
 
  This email sent to mark.wooll...@mac.com




-- 
http://ericd.net
Interactive design and development
___

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: iPhone: badge icon for a button in toolbar

2010-02-11 Thread Roland King
add UIBarButtonItem outlets to whatever class Files Owner is

eg

@property( readwrite, retain ) IBOutlet UIBarButtonItem *item1;

then you will be able to hook them up in IB. 

On 11-Feb-2010, at 9:57 PM, Eric E. Dolecki wrote:

 Awesome  - thank you!
 
 Now I am looking at how to access a certain UIBarButtonItem so I can set
 it's badge.
 
 In my app delegate I have a UITabBarController. In IB I can't seem to create
 an IBOutlet and wire the button I want up so I can set it's badge string.
 When I attempt to wire it up from File's Owner (MainWindow.xib), I only have
 the option Outlets -delegate.
 
 - (void)applicationDidFinishLaunching:(UIApplication *)application {
 
*// Add the tab bar controller's current view as a subview of the window
 *
 
[window addSubview:tabBarController.view];
 
 
 How do I access the button I want from the appDelegate?
 
 
 
 On Thu, Feb 11, 2010 at 8:46 AM, Mark Woollard mark.wooll...@mac.comwrote:
 
 See UITabBarItem's badgeValue property.
 
 Regards
 Mark
 
 On 11 Feb 2010, at 13:40, Eric E. Dolecki wrote:
 
 I know about placing a badge on the homescreen application icon, but is
 there a way to set this up for a button in a toolbar... or do I just use
 my
 own UIView to do the same thing and float it over the toolbar?
 
 Eric
 ___
 
 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/mark.woollard%40mac.com
 
 This email sent to mark.wooll...@mac.com
 
 
 
 
 -- 
 http://ericd.net
 Interactive design and development
 ___
 
 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/rols%40rols.org
 
 This email sent to r...@rols.org

___

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: iPhone: badge icon for a button in toolbar

2010-02-11 Thread Eric E. Dolecki
The class is UIApplication in IB. So it seems I can't do that?

On Thu, Feb 11, 2010 at 9:01 AM, Roland King r...@rols.org wrote:

 add UIBarButtonItem outlets to whatever class Files Owner is

 eg

@property( readwrite, retain ) IBOutlet UIBarButtonItem
 *item1;

 then you will be able to hook them up in IB.

 On 11-Feb-2010, at 9:57 PM, Eric E. Dolecki wrote:

  Awesome  - thank you!
 
  Now I am looking at how to access a certain UIBarButtonItem so I can set
  it's badge.
 
  In my app delegate I have a UITabBarController. In IB I can't seem to
 create
  an IBOutlet and wire the button I want up so I can set it's badge string.
  When I attempt to wire it up from File's Owner (MainWindow.xib), I only
 have
  the option Outlets -delegate.
 
  - (void)applicationDidFinishLaunching:(UIApplication *)application {
 
 *// Add the tab bar controller's current view as a subview of the
 window
  *
 
 [window addSubview:tabBarController.view];
 
 
  How do I access the button I want from the appDelegate?
 
 
 
  On Thu, Feb 11, 2010 at 8:46 AM, Mark Woollard mark.wooll...@mac.com
 wrote:
 
  See UITabBarItem's badgeValue property.
 
  Regards
  Mark
 
  On 11 Feb 2010, at 13:40, Eric E. Dolecki wrote:
 
  I know about placing a badge on the homescreen application icon, but is
  there a way to set this up for a button in a toolbar... or do I just
 use
  my
  own UIView to do the same thing and float it over the toolbar?
 
  Eric
  ___
 
  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/mark.woollard%40mac.com
 
  This email sent to mark.wooll...@mac.com
 
 
 
 
  --
  http://ericd.net
  Interactive design and development
  ___
 
  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/rols%40rols.org
 
  This email sent to r...@rols.org




-- 
http://ericd.net
Interactive design and development
___

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: iPhone: badge icon for a button in toolbar

2010-02-11 Thread Eric E. Dolecki
Ok - I hooked it up to the appdelegate... from another class I am doing this
(which bombs):

MyAppDelegate *ad = (MyAppDelegate *)[[UIApplication sharedApplication]
delegate];

UITabBar *tb = ad.tabBar;//works fine

UITabBarItem *tbi = [tb.items objectForIndex:1];*//bombs...*

So still trying to access that button at index 1




On Thu, Feb 11, 2010 at 9:09 AM, Eric E. Dolecki edole...@gmail.com wrote:

 The class is UIApplication in IB. So it seems I can't do that?


 On Thu, Feb 11, 2010 at 9:01 AM, Roland King r...@rols.org wrote:

 add UIBarButtonItem outlets to whatever class Files Owner is

 eg

@property( readwrite, retain ) IBOutlet UIBarButtonItem
 *item1;

 then you will be able to hook them up in IB.

 On 11-Feb-2010, at 9:57 PM, Eric E. Dolecki wrote:

  Awesome  - thank you!
 
  Now I am looking at how to access a certain UIBarButtonItem so I can set
  it's badge.
 
  In my app delegate I have a UITabBarController. In IB I can't seem to
 create
  an IBOutlet and wire the button I want up so I can set it's badge
 string.
  When I attempt to wire it up from File's Owner (MainWindow.xib), I only
 have
  the option Outlets -delegate.
 
  - (void)applicationDidFinishLaunching:(UIApplication *)application {
 
 *// Add the tab bar controller's current view as a subview of the
 window
  *
 
 [window addSubview:tabBarController.view];
 
 
  How do I access the button I want from the appDelegate?
 
 
 
  On Thu, Feb 11, 2010 at 8:46 AM, Mark Woollard mark.wooll...@mac.com
 wrote:
 
  See UITabBarItem's badgeValue property.
 
  Regards
  Mark
 
  On 11 Feb 2010, at 13:40, Eric E. Dolecki wrote:
 
  I know about placing a badge on the homescreen application icon, but
 is
  there a way to set this up for a button in a toolbar... or do I just
 use
  my
  own UIView to do the same thing and float it over the toolbar?
 
  Eric
  ___
 
  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/mark.woollard%40mac.com
 
  This email sent to mark.wooll...@mac.com
 
 
 
 
  --
  http://ericd.net
  Interactive design and development
  ___
 
  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/rols%40rols.org
 
  This email sent to r...@rols.org




 --
 http://ericd.net
 Interactive design and development




-- 
http://ericd.net
Interactive design and development
___

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: iPhone: badge icon for a button in toolbar

2010-02-11 Thread Eric E. Dolecki
It's objectAtIndex not objectForIndex ;) Sorry - it's working now.

On Thu, Feb 11, 2010 at 9:21 AM, Eric E. Dolecki edole...@gmail.com wrote:

 Ok - I hooked it up to the appdelegate... from another class I am doing
 this (which bombs):

 MyAppDelegate *ad = (MyAppDelegate *)[[UIApplication sharedApplication]
 delegate];

 UITabBar *tb = ad.tabBar;//works fine

 UITabBarItem *tbi = [tb.items objectForIndex:1];*//bombs...*

 So still trying to access that button at index 1




 On Thu, Feb 11, 2010 at 9:09 AM, Eric E. Dolecki edole...@gmail.comwrote:

 The class is UIApplication in IB. So it seems I can't do that?


 On Thu, Feb 11, 2010 at 9:01 AM, Roland King r...@rols.org wrote:

 add UIBarButtonItem outlets to whatever class Files Owner is

 eg

@property( readwrite, retain ) IBOutlet UIBarButtonItem
 *item1;

 then you will be able to hook them up in IB.

 On 11-Feb-2010, at 9:57 PM, Eric E. Dolecki wrote:

  Awesome  - thank you!
 
  Now I am looking at how to access a certain UIBarButtonItem so I can
 set
  it's badge.
 
  In my app delegate I have a UITabBarController. In IB I can't seem to
 create
  an IBOutlet and wire the button I want up so I can set it's badge
 string.
  When I attempt to wire it up from File's Owner (MainWindow.xib), I only
 have
  the option Outlets -delegate.
 
  - (void)applicationDidFinishLaunching:(UIApplication *)application {
 
 *// Add the tab bar controller's current view as a subview of the
 window
  *
 
 [window addSubview:tabBarController.view];
 
 
  How do I access the button I want from the appDelegate?
 
 
 
  On Thu, Feb 11, 2010 at 8:46 AM, Mark Woollard mark.wooll...@mac.com
 wrote:
 
  See UITabBarItem's badgeValue property.
 
  Regards
  Mark
 
  On 11 Feb 2010, at 13:40, Eric E. Dolecki wrote:
 
  I know about placing a badge on the homescreen application icon, but
 is
  there a way to set this up for a button in a toolbar... or do I just
 use
  my
  own UIView to do the same thing and float it over the toolbar?
 
  Eric
  ___
 
  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/mark.woollard%40mac.com
 
  This email sent to mark.wooll...@mac.com
 
 
 
 
  --
  http://ericd.net
  Interactive design and development
  ___
 
  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/rols%40rols.org
 
  This email sent to r...@rols.org




 --
 http://ericd.net
 Interactive design and development




 --
 http://ericd.net
 Interactive design and development




-- 
http://ericd.net
Interactive design and development
___

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: NSAttributtedString initWithHTML skip styles

2010-02-11 Thread Jens Alfke

On Feb 11, 2010, at 2:45 AM, Gustavo Pizano wrote:

 [(XWSDefaultComponentView *)[component view] setString:[valueString string]];

The -setString: method takes a plain NSString. So you stripped out your 
formatting when calling it.
To put an NSAttributedString into an NSTextView, you replace the contents of 
its textStorage object (which is a special type of mutable attributed string):
[[textView textStorage] setAttributedString: valueString];

—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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Copying CLHeading objects does not appear to work . . .

2010-02-11 Thread Michael A. Crawford
Here is the code (pertinent snippets)

@interface BlueSLRGPS ()
@property (copy) CLHeading* currentHeading;
@property (copy) CLLocation* currentLocation;
@property (retain) CLLocation* previousLocation;

- (NSString*)compassPointForHeading:(double)heading;

- (void)locationManager:(CLLocationManager*)manager
   didUpdateHeading:(CLHeading*)newHeading;

- (void)locationManager:(CLLocationManager*)manager
didUpdateToLocation:(CLLocation*)newLocation
   fromLocation:(CLLocation*)oldLocation;

- (void)locationManager:(CLLocationManager*)manager
   didFailWithError:(NSError*)error;
@end

@synthesize currentHeading;

- (void)locationManager:(CLLocationManager*)manager
   didUpdateHeading:(CLHeading*)newHeading
{
MCLog(@heading update isMainThread = %d, [NSThread isMainThread]);
MCLog(@Heading: %f, newHeading.magneticHeading);
self.currentHeading = newHeading;
[self.delegate headingUpdated];
}

Here is the result.

(gdb) p newHeading
$1 = (CLHeading *) 0x481ef50
(gdb) p currentHeading
$2 = (CLHeading *) 0x3c193c0
(gdb) po (CLHeading*)0x481ef50
magneticHeading 211.00 trueHeading 205.17 accuracy 35.00 x 2.625 y -6.875 z 
-18.250 @ 2010-02-11 11:18:29 AM
(gdb) po (CLHeading*)0x3c193c0
magneticHeading 0.00 trueHeading 0.00 accuracy 0.00 x 0.000 y 0.000 z 0.000 @ 
(null)

I didn't see anything in the docs about CLHeading objects not being copyable.  
Any ideas as to why the copy did not duplicate the current values?

-Michael

___

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


iPhone and OS X apps question

2010-02-11 Thread Eric E. Dolecki
I am looking at prototyping something and would like an iPhone app to be
able to talk with a desktop OS X app. Do something on the iPhone app, it's
reflected in the OS X application. And vice-versa. Where might I start for a
project like this?

Eric
___

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: iPhone and OS X apps question

2010-02-11 Thread Mark Ritchie

Hey Eric!
Over what timeframe did you want the iPhone app and the desktop app to  
be in sync?  Immediately?   ASAP? When iPhone is tether sync'd?  
Something else?
Is this one iPhone app to one desktop, all with the same user? Or is  
this many to many with many users? Something inbetween?
What behaviour do you envision when one or the other app is working  
'offline' , say on an airplane or in the metro?
And, of course, the fun question...  Who wins when there's a  
conflicting update? ;-)

Food for thought!
M.

Sent from my iPhone

On 2010-02-11, at 8:29, Eric E. Dolecki edole...@gmail.com wrote:

I am looking at prototyping something and would like an iPhone app  
to be
able to talk with a desktop OS X app. Do something on the iPhone  
app, it's
reflected in the OS X application. And vice-versa. Where might I  
start for a

project like this?

Eric
___

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/mark.ritchie 
%40mac.com


This email sent to mark.ritc...@mac.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: iPhone and OS X apps question

2010-02-11 Thread Ricky Sharp
I would begin with Apple's picture-sharing sample code. I think that  
sample has two parts - server and client. Ther is also an iPhone  
sample dealing with locating Bonjour services.


Basically Bonjour is used to have the server (Mac app) and client  
(iPhone) discover each other. Then use whatever networking protocol  
you want to send data.


This setup works extremely well in the simulator. When working with  
real hardware you will need to connect it (and your Mac) to the same  
wifi network. There is currently no public APIs to talk to a docked  
iPhone OS device.


Sent from my iPhone

On Feb 11, 2010, at 10:29 AM, Eric E. Dolecki edole...@gmail.com  
wrote:


I am looking at prototyping something and would like an iPhone app  
to be
able to talk with a desktop OS X app. Do something on the iPhone  
app, it's
reflected in the OS X application. And vice-versa. Where might I  
start for a

project like this?

Eric
___

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/rsharp%40mac.com

This email sent to rsh...@mac.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: Copying CLHeading objects does not appear to work . . .

2010-02-11 Thread Michael A. Crawford
It the copy failing because these are read-only properties?

-Michael

On Feb 11, 2010, at 11:29 AM, Michael A. Crawford wrote:

 Here is the code (pertinent snippets)
 
 @interface BlueSLRGPS ()
 @property (copy) CLHeading* currentHeading;
 @property (copy) CLLocation* currentLocation;
 @property (retain) CLLocation* previousLocation;
 
 - (NSString*)compassPointForHeading:(double)heading;
 
 - (void)locationManager:(CLLocationManager*)manager
   didUpdateHeading:(CLHeading*)newHeading;
 
 - (void)locationManager:(CLLocationManager*)manager
   didUpdateToLocation:(CLLocation*)newLocation
  fromLocation:(CLLocation*)oldLocation;
 
 - (void)locationManager:(CLLocationManager*)manager
  didFailWithError:(NSError*)error;
 @end
 
 @synthesize currentHeading;
 
 - (void)locationManager:(CLLocationManager*)manager
   didUpdateHeading:(CLHeading*)newHeading
 {
MCLog(@heading update isMainThread = %d, [NSThread isMainThread]);
MCLog(@Heading: %f, newHeading.magneticHeading);
self.currentHeading = newHeading;
[self.delegate headingUpdated];
 }
 
 Here is the result.
 
 (gdb) p newHeading
 $1 = (CLHeading *) 0x481ef50
 (gdb) p currentHeading
 $2 = (CLHeading *) 0x3c193c0
 (gdb) po (CLHeading*)0x481ef50
 magneticHeading 211.00 trueHeading 205.17 accuracy 35.00 x 2.625 y -6.875 z 
 -18.250 @ 2010-02-11 11:18:29 AM
 (gdb) po (CLHeading*)0x3c193c0
 magneticHeading 0.00 trueHeading 0.00 accuracy 0.00 x 0.000 y 0.000 z 0.000 @ 
 (null)
 
 I didn't see anything in the docs about CLHeading objects not being copyable. 
  Any ideas as to why the copy did not duplicate the current values?
 
 -Michael
 
 ___
 
 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/michaelacrawford%40me.com
 
 This email sent to michaelacrawf...@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/archive%40mail-archive.com

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


Re: What classes have -init?

2010-02-11 Thread Gordon Apple
It's unfortunate that all initializers don't at least call init
internally.  That would make subclassing easier if all one needs is to set a
few ivars.  In the earlier days of MacApp (Pascal and first C++ versions)
there was a basic initializer, similar to init, called by all classes,
just for that purpose.  Of course, Objective C at least sets them all to
zero, reducing the need -- but it still would have been useful, sometimes
eliminating the need to override multiple initializers.

Of course, you can always override init first, just to test whether it
gets called.  But then, there's no guarantee in future versions.

 
 True.
 
 But most classes have designated initializers that configure the class
 properly. They should be documented, although typically they‚re used for
 subclassing the class.
 
 
 On Feb 10, 2010, at 3:49 PM, Henry McGilton (Boulevardier) wrote:
 
 
 On Feb 10, 2010, at 12:23 PM, James Walker wrote:
 
 I think at times I've written things like [[NSMutableArray alloc] init] with
 no apparent ill effects, but now I notice that the docs for NSMutableArray
 and NSArray don't say that there is an init method.  The NSObject docs say
 that an init method might raise an exception.  Is there some other init rule
 that I've missed, or have I just gotten lucky?
 
 When in doubt, remember to look at the super-class documentation:
 
 http://developer.apple.com/mac/library/documentation/cocoa/reference/Foundati
 on/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/doc/uid/20
 50-init
 
 All classes that inherit from NSObject (which means pretty much
 all of them) inherit NSObject's   ˆinit   method, and that's assumed
 or implicit in the Array examples you referenced above . . .
 
 
 



___

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: iPhone and OS X apps question

2010-02-11 Thread Eric E. Dolecki
To clarify what I'm looking to do...

I have a wifi router attached to the back of my Mac. My Touch connects to
that router.

I'd like to run an app on the Touch and an app on the Mac. I'd like to be
able to send a simple string from either app to the other and acknowledge
receipt of that.

Swipe on the Touch, the Mac app's UI displays got the swipe - and press a
button or something on the Mac and it tells the Touch app got the button

Once I get communication going, I plan on making the behaviors more
interesting. ASAP as far as timing goes. It's not for a real world product,
just prototyping for an idea.

I have no experience with Bonjour or sockets on this platform... could I
open sockets in each app and then have them talk that way? If yes, is there
sample code someplace that basically does this?

The Touch app could talk to a Flash app running on the Mac too - doesn't
need to be a OS X application.

Eric


On Thu, Feb 11, 2010 at 11:47 AM, Ricky Sharp rsh...@mac.com wrote:

 I would begin with Apple's picture-sharing sample code. I think that sample
 has two parts - server and client. Ther is also an iPhone sample dealing
 with locating Bonjour services.

 Basically Bonjour is used to have the server (Mac app) and client (iPhone)
 discover each other. Then use whatever networking protocol you want to send
 data.

 This setup works extremely well in the simulator. When working with real
 hardware you will need to connect it (and your Mac) to the same wifi
 network. There is currently no public APIs to talk to a docked iPhone OS
 device.

 Sent from my iPhone


 On Feb 11, 2010, at 10:29 AM, Eric E. Dolecki edole...@gmail.com
 wrote:

  I am looking at prototyping something and would like an iPhone app to be
 able to talk with a desktop OS X app. Do something on the iPhone app, it's
 reflected in the OS X application. And vice-versa. Where might I start for
 a
 project like this?

 Eric
 ___

 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/rsharp%40mac.com

 This email sent to rsh...@mac.com




-- 
http://ericd.net
Interactive design and development
___

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: iPhone and OS X apps question

2010-02-11 Thread Jens Alfke

On Feb 11, 2010, at 8:47 AM, Ricky Sharp wrote:

 Basically Bonjour is used to have the server (Mac app) and client (iPhone) 
 discover each other. Then use whatever networking protocol you want to send 
 data.

I wrote an open-source Mac/iPhone networking framework that makes this job 
easier (both the Bonjour part and the protocol part):
http://bitbucket.org/snej/mynetwork/
The API lets you send messages, which are similar to NSDictionaries, and get 
replies to them. It's asynchronous, and multiple messages and replies can be in 
flight in both directions.

—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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Find in a WebKit view?

2010-02-11 Thread Mike Abdullah
WebDocumentSearching is your man.

On 11 Feb 2010, at 04:12, Peter N Lewis wrote:

 Is there any way to add support for the normal Cocoa Find functionality in a 
 WebKit view?
 
 Failing that, is there any other way to get search functionality in a WebKit 
 view?  I want to do some in-app documentation, and Apple's Help system is so 
 bad I've finally given up on that (floating window!?!), but without being 
 able to search the web page, it is a bit limited.
 
 Ideally 10.5+, but I'd accept a 10.6+ solution.
 
 Thanks,
   Peter.
 
 -- 
 Keyboard Maestro 4.0.2 now released!  Brand new interface!
 
 Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac
 http://www.stairways.com/   http://download.stairways.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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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/archive%40mail-archive.com

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


Re: Core Data Issue with Binding

2010-02-11 Thread Mike Abdullah

On 10 Feb 2010, at 20:03, Kyle Sluder wrote:

 On Wed, Feb 10, 2010 at 9:26 AM, Matthew Miller mattmille...@mac.com wrote:
 @property (nonatomic, retain) NSDate *DateOfBirth;
 @property (nonatomic, retain) NSString *FirstName;
 @property (nonatomic, retain) NSString *LastName;
 @property (nonatomic, retain) NSNumber *DraftClass;
 @property (nonatomic, retain) NSNumber *DraftPick;
 @property (nonatomic, assign) BOOL Retired;
 @property (nonatomic, retain) NSSet *PlaysFor;
 @property (nonatomic, retain) Program *School;
 
 @property (readonly) NSString *DisplayName;
 
 These are not KVC-compliant property names. You must rename these with
 lowercase initial letters, like dateOfBirth, firstName, etc.

Not true, they are KVC-compliant. However, they *are* unwise and you should 
follow Kyle's advice.___

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: What classes have -init?

2010-02-11 Thread James Walker

On 2/10/2010 8:38 PM, Quincey Morris wrote:

On Feb 10, 2010, at 12:23 PM, James Walker wrote:


I think at times I've written things like [[NSMutableArray alloc]
init] with no apparent ill effects, but now I notice that the docs for
NSMutableArray and NSArray don't say that there is an init method. The
NSObject docs say that an init method might raise an exception. Is there
some other init rule that I've missed, or have I just gotten lucky?


It's worthwhile keeping this in mind:


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW3

Particularly:

When you define a subclass you must be able to identify the
designated initializer of the superclass and invoke it in your
subclass’s designated initializer through a message to super. You
must also make sure that inherited initializers are covered in some
way.

Applying that [conceptually] to NSArray, say, there's no actual luck
involved. If 'init' is a designated initializer, it should be
documented in the class reference and there's no problem. If not,
then NSArray *must* ensure that calling it results in one of its real
designated initializers being called, *or* must produce an
error.


If it produces an error that I'm not expecting, that would be bad.  What 
I was wondering was how I knew whether it would produce an error, other 
than by just testing on every version of the OS that I care about.


In a previous reply, Henry McGilton pointed out that the NSObject 
documentation states that its implementation of init does not produce an 
error.  Therefore, any subclass that doesn't override init does not 
produce an error.

--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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


setWidth pop-up list of NSComboBox

2010-02-11 Thread John Yeh
How to change the width of the pop-up list in NSComboBox? When a long string is 
added to the NSComboBox, it can't displayed completely. how to extend the width 
of the pop-up list?
-John___

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: What classes have -init?

2010-02-11 Thread Scott Ribe
 ...but it still would have been useful, sometimes
 eliminating the need to override multiple initializers.

Are you missing the point of the designated initializer? Or have you dealt
with classes that did not have one, or did not use it properly?

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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


No Methods being called in my subclassed NSArrayController

2010-02-11 Thread Tony Romano
Environment:

1. Core Data, Document based app.
2. UI contains a NSTableView, Add, Remove, ...  
3. NSArrayController.

The App works fine, I can Add/Remove objects, Save/Load Works, Undo Works. 

Problem:

I am trying to override the -(id)newObject  method to change one of the UI 
elements in the Window as part of the 'Add' operation.  So, I created a new 
class derived from NSArrayController, implemented the newObject method and it 
never gets called.  In fact, I've stubbed several other methods of 
NSArrayController and NONE of them get called.

What am I missing? 

Thanks in advance!

-tony


___

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: No Methods being called in my subclassed NSArrayController

2010-02-11 Thread Fritz Anderson
On 11 Feb 2010, at 1:20 PM, Tony Romano wrote:

 Environment:
 
 1. Core Data, Document based app.
 2. UI contains a NSTableView, Add, Remove, ...  
 3. NSArrayController.
 
 The App works fine, I can Add/Remove objects, Save/Load Works, Undo Works. 
 
 Problem:
 
 I am trying to override the -(id)newObject  method to change one of the UI 
 elements in the Window as part of the 'Add' operation.  So, I created a new 
 class derived from NSArrayController, implemented the newObject method and it 
 never gets called.  In fact, I've stubbed several other methods of 
 NSArrayController and NONE of them get called.
 
 What am I missing? 

The first thing I'd look for is whether you're using your subclass when you 
instantiate the array controller. I assume you do this in the NIB. When you 
select the array controller and look at the Identity inspector, what class does 
it show?

— 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/archive%40mail-archive.com

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


iPhone: UIWebView not displaying until scrolled?

2010-02-11 Thread Eric E. Dolecki
I am animating a UIWebView after it's loaded - but it doesn't display
anything unless I scroll it a little bit. If I call [webView reload]; my
webViewDidFinishLoad gets called - and that is where I put my [webView
reload] call to fix the display. What is the workaround aside from placing
the UIWebView in the main screen a few pixels?

-- 
http://ericd.net
Interactive design and development
___

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: What classes have -init?

2010-02-11 Thread Greg Parker
On Feb 11, 2010, at 9:03 AM, Gordon Apple wrote:
 It's unfortunate that all initializers don't at least call init
 internally.  That would make subclassing easier if all one needs is to set a
 few ivars.  In the earlier days of MacApp (Pascal and first C++ versions)
 there was a basic initializer, similar to init, called by all classes,
 just for that purpose.  Of course, Objective C at least sets them all to
 zero, reducing the need -- but it still would have been useful, sometimes
 eliminating the need to override multiple initializers.

The designated initializer pattern solves the problem in a similar way. Every 
initializer in a class is expected to call through that class's designated 
initializer eventually. When you subclass a class, you can override just the 
designated initializer to do your work and then call super's designated 
initializer. All of the superclass's other initializers will funnel through 
your code without any additional overrides.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler

___

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: What classes have -init?

2010-02-11 Thread Gordon Apple
My point was that if you could count on init being called internally and
all you needed was to initialize some ivars, you could override init and
not have to override the (sometimes more involved) designated initializer
and possibly other initializers.  You could still use the (superclass)
designated initializer or a class-level instantiator without overriding it.

This relates to a long ago discussion about the fact that class-level
instantiators, e.g., [someClass  someClassWithMoreStuff], should (and I
think do) always use the class designation self so that they always
instantiated the subclass object and not the superclass object.


On 2/11/10 12:59 PM, Scott Ribe scott_r...@killerbytes.com wrote:

 ...but it still would have been useful, sometimes
 eliminating the need to override multiple initializers.
 
 Are you missing the point of the designated initializer? Or have you dealt
 with classes that did not have one, or did not use it properly?



___

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: What classes have -init?

2010-02-11 Thread mmalc Crawford

On Feb 11, 2010, at 12:08 pm, Gordon Apple wrote:

 My point was that if you could count on init being called internally and
 all you needed was to initialize some ivars, you could override init and
 not have to override the (sometimes more involved) designated initializer
 and possibly other initializers.  You could still use the (superclass)
 designated initializer or a class-level instantiator without overriding it.
 
Please read The Designated Initializer in 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html,
 in particular the section starting Figure 3-3  Covering the Designated 
Initializer.

mmalc

___

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: iPhone: UIWebView not displaying until scrolled?

2010-02-11 Thread Peter Blazejewicz
Hi Eric,

can you post how your web view is animated?
If I setup quick test case:

@implementation WebViewController
@synthesize webView;


- (void)viewDidLoad
{
[super viewDidLoad];
self.webView.delegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@index
ofType:@html];
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
self.webView.alpha = 0.0;
[url release]; url = nil;
}
- (void)viewDidUnload
{
self.webView = nil;
}

- (void)dealloc
{
[webView release]; webView = nil;
[super dealloc];
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString *loadHandlerStr = @window.pageLoaded();
[self.webView stringByEvaluatingJavaScriptFromString:loadHandlerStr];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.webView.alpha = 1.0;
[UIView commitAnimations];
}
@end

both UIWebView is animated (and visible) and also content within html
web page is drawn (and animated):
(JavaScript/CSS)
from opacity 0.0:
 -webkit-transition: opacity 2s linear;

to 1.0:
elem.style.opacity = 1.0;

maybe that is some different issue that somehow became apparent on
your web view use,

regards,
Peter Blazejewicz
On Thu, Feb 11, 2010 at 8:40 PM, Eric E. Dolecki edole...@gmail.com wrote:
 I am animating a UIWebView after it's loaded - but it doesn't display
 anything unless I scroll it a little bit. If I call [webView reload]; my
 webViewDidFinishLoad gets called - and that is where I put my [webView
 reload] call to fix the display. What is the workaround aside from placing
 the UIWebView in the main screen a few pixels?

 --
 http://ericd.net
 Interactive design and development
___

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: No Methods being called in my subclassed NSArrayController

2010-02-11 Thread Tony Romano
Thanks for the reply Fritz.

It shows NSArrayController and it is greyed out.  It list two options in the 
drop down,  NSArrayController and NSDictionaryController.  If I try to add my 
controller class's name, IB beeps and won't accept the name.  (I forgot to 
mention in my original post that the Prepares Content is checked on the 
attributes page).

I'm sure it is something silly I am doing.

-tony
On Feb 11, 2010, at 11:27 AM, Fritz Anderson wrote:

 On 11 Feb 2010, at 1:20 PM, Tony Romano wrote:
 
 Environment:
 
 1. Core Data, Document based app.
 2. UI contains a NSTableView, Add, Remove, ...  
 3. NSArrayController.
 
 The App works fine, I can Add/Remove objects, Save/Load Works, Undo Works. 
 
 Problem:
 
 I am trying to override the -(id)newObject  method to change one of the UI 
 elements in the Window as part of the 'Add' operation.  So, I created a new 
 class derived from NSArrayController, implemented the newObject method and 
 it never gets called.  In fact, I've stubbed several other methods of 
 NSArrayController and NONE of them get called.
 
 What am I missing? 
 
 The first thing I'd look for is whether you're using your subclass when you 
 instantiate the array controller. I assume you do this in the NIB. When you 
 select the array controller and look at the Identity inspector, what class 
 does it show?
 
   — F
 
 

-tony


___

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: iPhone: UIWebView not displaying until scrolled?

2010-02-11 Thread Eric E. Dolecki
I fixed it - the problem lies when the UIWebView is loaded, but it's not on
screen - it's center is off screen. When I animate it into view on the
Touch, it's blank until I scroll it a little. Now, before I call my
animation, I have the webView reload, then its' animated into view and it
works.

Eric

On Thu, Feb 11, 2010 at 3:36 PM, Peter Blazejewicz 
peter.blazejew...@gmail.com wrote:

 Hi Eric,

 can you post how your web view is animated?
 If I setup quick test case:

 @implementation WebViewController
 @synthesize webView;


 - (void)viewDidLoad
 {
[super viewDidLoad];
self.webView.delegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@index
 ofType:@html];
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
[self.webView loadRequest:[NSURLRequest requestWithURL:url]];
self.webView.alpha = 0.0;
[url release]; url = nil;
 }
 - (void)viewDidUnload
 {
self.webView = nil;
 }

 - (void)dealloc
 {
[webView release]; webView = nil;
[super dealloc];
 }

 -(void)webViewDidFinishLoad:(UIWebView *)webView
 {
NSString *loadHandlerStr = @window.pageLoaded();
[self.webView stringByEvaluatingJavaScriptFromString:loadHandlerStr];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
self.webView.alpha = 1.0;
[UIView commitAnimations];
 }
 @end

 both UIWebView is animated (and visible) and also content within html
 web page is drawn (and animated):
 (JavaScript/CSS)
 from opacity 0.0:
  -webkit-transition: opacity 2s linear;

 to 1.0:
 elem.style.opacity = 1.0;

 maybe that is some different issue that somehow became apparent on
 your web view use,

 regards,
 Peter Blazejewicz
 On Thu, Feb 11, 2010 at 8:40 PM, Eric E. Dolecki edole...@gmail.com
 wrote:
  I am animating a UIWebView after it's loaded - but it doesn't display
  anything unless I scroll it a little bit. If I call [webView reload]; my
  webViewDidFinishLoad gets called - and that is where I put my [webView
  reload] call to fix the display. What is the workaround aside from
 placing
  the UIWebView in the main screen a few pixels?
 
  --
  http://ericd.net
  Interactive design and development




-- 
http://ericd.net
Interactive design and development
___

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 Issue with Binding

2010-02-11 Thread Kyle Sluder
On Thu, Feb 11, 2010 at 9:55 AM, Mike Abdullah
cocoa...@mikeabdullah.net wrote:
 Not true, they are KVC-compliant. However, they *are* unwise and you should 
 follow Kyle's advice.

I can't find anywhere that specifically addresses the capitalization
issue. The only thing I've found that comes close is the note on
typographical conventions at the top of Key-Vaule Coding Accessor
Methods in the Key-Value Coding Programming Guide[1], which uses
key and Key to distinguish between lowercase and capitalized
forms. But that of course doesn't explicitly form part of the API
contract.

--Kyle Sluder

[1] 
http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174
___

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: Insert, Fetch, Re-Fetch. Same Object?

2010-02-11 Thread Jerry Krinock
Thanks for your input, atze.  I believe you.  But to confirm it, we need the 
documentation.

On 2010 Feb 11, at 00:19, Alexander Spohr wrote:

 Every NSManagedObjectContext holds its own but unique copy of your object.

I understand that each managed object context makes separate copies, but I 
wouldn't say that it necessarily follows from this that any given managed 
object context could not create more than one.

 This is because the object in the sql-store needs a primary key I would 
 have thought that your inserted object gets the persistent key set and will 
 therefore be the same object as the fetched ones. But I did not check your 
 code for a misconfiguration.

Well, it works as I said.

 No, you will always get the same object. Because this was why CoreData and 
 EOF where made for. Exactly this.

That's what I'm looking for.  If anyone can find always get the same object 
in the API documentation, please do so.

___

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: Insert, Fetch, Re-Fetch. Same Object?

2010-02-11 Thread mmalc Crawford

On Feb 10, 2010, at 7:07 pm, Jerry Krinock wrote:

 Yes, basically. There is only going to be one in-memory object at a time 
 that represents the same managed object.
 
 It certainly seems to be sensible, but I just wish someone could find such 
 documentation.  I can't.
 
Uniquing: 
http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdGlossary.html#//apple_ref/doc/uid/TP40001651-TP1

http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdFaultingUniquing.html#//apple_ref/doc/uid/TP30001202

From Core Data Basics
http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdBasics.html#//apple_ref/doc/uid/TP40001650
You may have more than one managed object context in your application. For 
every object in a persistent store there may be at most one corresponding 
managed object associated with a given context (for more details, see “Faulting 
and Uniquing”).


mmalc

___

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


[iPhone] custom CALayer drawing

2010-02-11 Thread PCWiz
I'm trying to do some custom drawing in a CALayer subclass by overriding the 
drawInContext: method, but it appears that its not being called. In my subclass 
I just have this:

- (void)drawInContext:(CGContextRef)theContext
{
NSLog(@drawInContext called);
}

Then in the viewDidLoad method of my view controller I have this:

CustomLayer *lines = [CustomLayer layer];
[self.view.layer addSublayer:lines];

However, the drawInContext method is never called. What am I doing wrong 
here?___

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 Issue with Binding

2010-02-11 Thread Mike Abdullah

On 11 Feb 2010, at 21:50, Kyle Sluder wrote:

 On Thu, Feb 11, 2010 at 9:55 AM, Mike Abdullah
 cocoa...@mikeabdullah.net wrote:
 Not true, they are KVC-compliant. However, they *are* unwise and you should 
 follow Kyle's advice.
 
 I can't find anywhere that specifically addresses the capitalization
 issue. The only thing I've found that comes close is the note on
 typographical conventions at the top of Key-Vaule Coding Accessor
 Methods in the Key-Value Coding Programming Guide[1], which uses
 key and Key to distinguish between lowercase and capitalized
 forms. But that of course doesn't explicitly form part of the API
 contract.

Fair enough. The main reason why such a thing is legal is that you sometimes 
need a method like -URL or -HTMLString, so the system supports this.
 
 
 [1] 
 http://developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#//apple_ref/doc/uid/20002174

___

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: NSXML and

2010-02-11 Thread Keith Blount
For the sake of the archives, and in case anyone else comes across this problem 
(anyone using the NSXML classes should at least be aware of it), here is the 
workaround I have settled on.

I have created my own NSXMLDocument category to generate NSData using 
-XMLDataWithOptions: that then escapes any potentially dodgy occurrences of ‘’ 
by loading that data object into an NSString. Here is the category method:

@implementation NSXMLDocument (BugWorkaround)

/*
 *NOTE: This method works around a bug in the Cocoa NSXML classes, which refuse 
to escape '' in any situation.
 *According to section 2.4 of the XML specs ( 
http://www.w3.org/TR/REC-xml/#syntax ), '' and '' must always
 *be escaped, but '' only needs escaping when it appears in the character 
sequence ']]', unless it marks the
 *end of a CDATA block (or a conditional section - see section 3.4). The Cocoa 
NSXML classes correctly escape
 *'' and '' to 'lt;' and 'amp;', but *never* escape '', even when it 
appears in the string ']]' inside an
 *element's -stringValue. This generates invalid XML, and NSXMLDocument will 
refuse to read invalid XML unless
 *NSXMLDocumentTidyXML is set, but that messes up all the white space.
 *This method therefore generates NSData from the NSXMLDocument, then reads 
that data into an NSString. It then
 *looks for the ']]' sequence. If it finds it, it looks for the '![' 
sequence, which opens a conditional section
 *or CDATA block. If '![' is *not* found in the XML string, then we can safely 
assume that any occurrences of
 *']]' must appear only in places where it should be escaped to ']]gt;' in 
order to create valid XML. This method
 *replaces such instances with an escaped version of the string.
 */
- (NSData *)XMLDataWithPrettyPrintAndExtraEscapes
{
// First, get the data.
NSData*data = [selfXMLDataWithOptions:NSXMLNodePrettyPrint];
// Then, read the resulting XML string.
NSMutableString*str = [[NSMutableStringalloc] initWithData:data 
encoding:NSUTF8StringEncoding];
// Does this XML contain the character sequence ']]'?
// If not, do nothing - just return the data as-is, as the NSXML classes
// will have escaped everything that needed escaping.
NSRange range = [str rangeOfString:@]]];
if (range.length == 0)
{
[str release];
return data;
}
// If it does contain these characters, though, we need to do some checks. This 
sequence
// of characters should only appear at the end of a CDATA or conditional 
sequence. If the ']]'
// string appears anywhere else - i.e. in content - then the '' *must* be 
escaped to 'gt;'.
// We thus check to see if this XML contains any CDATA or conditional sequences 
by looking for
// '![' (CDATA and conditional sections always begin '![', e.g. 
'![CDATA[...]]'.).
NSRange conditionalRange = [str rangeOfString:@![];
if (conditionalRange.length  0)
{
// If the document contains any CDATA or conditional sequences,  bail and do 
nothing - we'll
// just have to leave it to the user to ensure that there is no invalid ']]' 
sequences within
// the content. We don't want to escape any ']]' sequences that should not be 
escaped, and
// checking which ones should and shouldn't be escaped gets too complicated for 
our purposes.
[str release];
return data;
}
// If we got here, the XML document contains the ']]' sequence only in places 
that are *not* ending CDATA
// or conditional sequences (because we know there are no such sequences in 
this document). This is bad XML,
// so we replace all of the occurrences of this string with the correct 
']]gt;' escaped version, and then
// generate and return our own data object from our string.
[str 
replaceOccurrencesOfString:@]]withString:@]]gt;options:0range:NSMakeRange(range.location,
 [str length]-range.location)];
data = [str dataUsingEncoding:NSUTF8StringEncoding];
[str release];
return data;
}

@end

I’ve also filed this as a bug - #7637981.

--- ORIGINAL MESSAGE ---

Still working on this and still getting nowhere, so another question:

Is there a way to prevent NSXMLElement converting '' into 'amp' so that I can 
resolve character entities myself in my own NSXMLElement category -init... 
method?

To recap the problem, the NSXML classes change '' into 'lt;' and '' into 
'amp;' (when in string value content), just as they should according to the 
XML specs. But they don't convert '' into 'gt;'. This is fine as the XML 
specs don't require this in most situations, but if '' appears in the string 
']]' (when not ending CDATA) then it must be escaped - but Apple's NSXML 
classes don't do this, generating invalid XML that cannot be opened by 
NSXMLDocument in this situation.

I tried creating my own -initWithName:validStringValue: method which did some 
jiggery-pokery and then called -initWithXMLString:, thinking that this wouldn't 
do any conversion, the idea being that I could force ']]' to appear as 
']]gt;' myself by creating the XML string directly rather than going through 
-setStringValue. But no. If you try this:

NSXMLElement *element = 

Re: [iPhone] custom CALayer drawing

2010-02-11 Thread Bob Barnes
  Have you tried calling setNeedsDisplay on the view? You need to request that 
a view redraw when the data or state used for drawing a view changes.

Bob

On Feb 11, 2010, at 3:44 PM, PCWiz wrote:

 I'm trying to do some custom drawing in a CALayer subclass by overriding the 
 drawInContext: method, but it appears that its not being called. In my 
 subclass I just have this:
 
 - (void)drawInContext:(CGContextRef)theContext
 {
NSLog(@drawInContext called);
 }
 
 Then in the viewDidLoad method of my view controller I have this:
 
 CustomLayer *lines = [CustomLayer layer];
 [self.view.layer addSublayer:lines];
 
 However, the drawInContext method is never called. What am I doing wrong 
 here?___
 
 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/toadfoot%40comcast.net
 
 This email sent to toadf...@comcast.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/archive%40mail-archive.com

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


Re: No Methods being called in my subclassed NSArrayController

2010-02-11 Thread Jerry Krinock

On 2010 Feb 11, at 13:25, Tony Romano wrote:

 Thanks for the reply Fritz.
 
 It shows NSArrayController and it is greyed out.  It list two options in the 
 drop down,  NSArrayController and NSDictionaryController.  If I try to add my 
 controller class's name, IB beeps and won't accept the name.  (I forgot to 
 mention in my original post that the Prepares Content is checked on the 
 attributes page).

1.  Make sure that your subclass is declared as @interface MyArrayController : 
NSArrayController
2.  Make sure that this is in a .h file which is included in your project.  
(Put some garbage text into it and see if it compiles.)
3.  Save the file.
4.  In Interface Builder, click File  Reload All Class Files.

Now check that drop down again.

I have subclassed NSArrayController like this and it works fine.

___

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: [iPhone] custom CALayer drawing

2010-02-11 Thread David Duncan
On Feb 11, 2010, at 3:44 PM, PCWiz wrote:

 I'm trying to do some custom drawing in a CALayer subclass by overriding the 
 drawInContext: method, but it appears that its not being called. In my 
 subclass I just have this:
 
 However, the drawInContext method is never called. What am I doing wrong here?

Layers (unlike views) start life validated. You need to call the layer's 
-setNeedsDisplay method for your -drawInContext: method to be called, so you 
should add a [lines setNeedsDisplay] call at some point.
--
David Duncan
Apple DTS Animation and Printing

___

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: [iPhone] custom CALayer drawing

2010-02-11 Thread PCWiz
Tried it, my code looks like this now:

CustomLayer *lines = [CustomLayer layer];
[self.view.layer addSublayer:lines];
[lines setNeedsDisplay];

Still nothing. Am I calling setNeedsDisplay at the wrong place?

On 2010-02-11, at 5:39 PM, Bob Barnes wrote:

   Have you tried calling setNeedsDisplay on the view? You need to request 
 that a view redraw when the data or state used for drawing a view changes.
 
 Bob
 
 On Feb 11, 2010, at 3:44 PM, PCWiz wrote:
 
 I'm trying to do some custom drawing in a CALayer subclass by overriding the 
 drawInContext: method, but it appears that its not being called. In my 
 subclass I just have this:
 
 - (void)drawInContext:(CGContextRef)theContext
 {
NSLog(@drawInContext called);
 }
 
 Then in the viewDidLoad method of my view controller I have this:
 
 CustomLayer *lines = [CustomLayer layer];
 [self.view.layer addSublayer:lines];
 
 However, the drawInContext method is never called. What am I doing wrong 
 here?___
 
 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/toadfoot%40comcast.net
 
 This email sent to toadf...@comcast.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/archive%40mail-archive.com

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


Re: [iPhone] custom CALayer drawing

2010-02-11 Thread PCWiz
Yep, I just tried that (sent a reply a minute ago) but the drawInContext: 
method still isn't being called.


Independent Cocoa Developer, Macatomy Software
http://macatomy.com


On 2010-02-11, at 5:47 PM, David Duncan wrote:

 On Feb 11, 2010, at 3:44 PM, PCWiz wrote:
 
 I'm trying to do some custom drawing in a CALayer subclass by overriding the 
 drawInContext: method, but it appears that its not being called. In my 
 subclass I just have this:
 
 However, the drawInContext method is never called. What am I doing wrong 
 here?
 
 Layers (unlike views) start life validated. You need to call the layer's 
 -setNeedsDisplay method for your -drawInContext: method to be called, so you 
 should add a [lines setNeedsDisplay] call at some point.
 --
 David Duncan
 Apple DTS Animation and Printing
 

___

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: No Methods being called in my subclassed NSArrayController

2010-02-11 Thread Tony Romano
The Reload All Class files did it!. Thanks!

On Feb 11, 2010, at 4:46 PM, Jerry Krinock wrote:

 
 On 2010 Feb 11, at 13:25, Tony Romano wrote:
 
 Thanks for the reply Fritz.
 
 It shows NSArrayController and it is greyed out.  It list two options in the 
 drop down,  NSArrayController and NSDictionaryController.  If I try to add 
 my controller class's name, IB beeps and won't accept the name.  (I forgot 
 to mention in my original post that the Prepares Content is checked on the 
 attributes page).
 
 1.  Make sure that your subclass is declared as @interface MyArrayController 
 : NSArrayController
 2.  Make sure that this is in a .h file which is included in your project.  
 (Put some garbage text into it and see if it compiles.)
 3.  Save the file.
 4.  In Interface Builder, click File  Reload All Class Files.
 
 Now check that drop down again.
 
 I have subclassed NSArrayController like this and it works fine.
 
 ___
 
 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/tonyrom%40hotmail.com
 
 This email sent to tony...@hotmail.com
 

-tony


___

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


[iPhone] CALayer/UIView ordering

2010-02-11 Thread PCWiz
In my UIViewController I create a CAGradientLayer in the viewDidLoad method:

CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = CGRectMake(self.view.bounds.origin.x, 
self.view.bounds.origin.y + 44.0, self.view.bounds.size.width, 
self.view.bounds.size.height - 44.0);
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor 
colorWithRed:0.953 green:0.961 blue:0.965 alpha:1.00] CGColor], (id)[[UIColor 
colorWithRed:0.729 green:0.749 blue:0.792 alpha:1.00] CGColor], nil];
[self.view.layer addSublayer:gradient];

The gradient works fine. Now this view has a subview (custom UIView subclass, 
added in Interface Builder) that draws a line. The problem is that the 
CAGradientLayer goes OVER the subview of the main view. If I comment out the 
code that creates the CAGradientLayer, I can see the contents of the subview 
just fine. Is there any way to make this CAGradientLayer go UNDER the subview?

Independent Cocoa Developer, Macatomy Software
http://macatomy.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: [iPhone] custom CALayer drawing

2010-02-11 Thread David Duncan
On Feb 11, 2010, at 4:50 PM, PCWiz wrote:

 Yep, I just tried that (sent a reply a minute ago) but the drawInContext: 
 method still isn't being called.


Its because your layer is still sized 0,0. Not much you can draw into a layer 
that size :).
--
David Duncan
Apple DTS Animation and Printing

___

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: [iPhone] custom CALayer drawing

2010-02-11 Thread PCWiz
Thanks, setting the layer frame to an appropriate size did the trick :)


Independent Cocoa Developer, Macatomy Software
http://macatomy.com


On 2010-02-11, at 5:55 PM, David Duncan wrote:

 On Feb 11, 2010, at 4:50 PM, PCWiz wrote:
 
 Yep, I just tried that (sent a reply a minute ago) but the drawInContext: 
 method still isn't being called.
 
 
 Its because your layer is still sized 0,0. Not much you can draw into a layer 
 that size :).
 --
 David Duncan
 Apple DTS Animation and Printing
 

___

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: [iPhone] CALayer/UIView ordering

2010-02-11 Thread David Duncan
On Feb 11, 2010, at 4:54 PM, PCWiz wrote:

 The gradient works fine. Now this view has a subview (custom UIView subclass, 
 added in Interface Builder) that draws a line. The problem is that the 
 CAGradientLayer goes OVER the subview of the main view. If I comment out the 
 code that creates the CAGradientLayer, I can see the contents of the subview 
 just fine. Is there any way to make this CAGradientLayer go UNDER the subview?


Views and Layers share the same geometric ordering, that is what a view draws 
over is dependent on the order of its corresponding layer. Your effectively 
adding your gradient layer after all of the other view's that your view 
controller loaded, thus it is drawing over the other views and their 
subviews/layers.

You need to either insert the gradient layer into the sublayers array first, or 
move the views that should be on top to after. You may also want to consider 
creating a UIView subclass that returns [CAGradientLayer class] from its 
+layerClass method and exports methods to configure the gradient layer, then 
you can do your layout in IB (although you would still need to configure it in 
code).
--
David Duncan
Apple DTS Animation and Printing

___

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: What classes have -init?

2010-02-11 Thread Gordon Apple
I have read it.  My point was that if all Cocoa classes called init
somewhere in their other initializers (or had a two-step initialization
similar to what MacApp did), then you could simply override (not call)
init for simple ivar initialization in a subclass, which would in no way
interfere with a designated initializer.  Since they don't all call it, it's
really academic.


On 2/11/10 6:52 PM, cocoa-dev-requ...@lists.apple.com
cocoa-dev-requ...@lists.apple.com wrote:

 Message: 2
 Date: Thu, 11 Feb 2010 12:18:55 -0800
 From: mmalc Crawford mmalc_li...@me.com
 Subject: Re: What classes have -init?
 To: Cocoa-Dev List cocoa-dev@lists.apple.com
 Message-ID: 6ea60c25-38cb-447a-832f-96f17a865...@me.com
 Content-Type: text/plain; charset=us-ascii
 
 
 On Feb 11, 2010, at 12:08 pm, Gordon Apple wrote:
 
 My point was that if you could count on init being called internally and
 all you needed was to initialize some ivars, you could override init and
 not have to override the (sometimes more involved) designated initializer
 and possibly other initializers.  You could still use the (superclass)
 designated initializer or a class-level instantiator without overriding it.
 
 Please read The Designated Initializer in
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Objecti
 veC/Articles/ocAllocInit.html, in particular the section starting Figure 3-3
 Covering the Designated Initializer.
 
 mmalc



___

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


Creating an Application Support folder

2010-02-11 Thread Paul Johnson
I'm trying to find a best way to create the Application Support
folder. I'm rather new at Cocoa so it's taking me a while to do even
this simple thing. I'm also interested in ensuring my application can
be localized easily.

I have a function - (NSString *)applicationSupportFolder that
returns the desired folder name, properly localized. I call this
function and then use NSFileManager to check for the existence of the
folder. Because there can be a file (NOT a folder) already bearing the
folder name, I need to handle that possibility. Everything I've found
on the internet just ignores this case.

Can anyone recommend what I should do?
___

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


Best class for pixel-level image processing?

2010-02-11 Thread Alexander Golec
I am writing an application that wants to perform some basic computer vision 
computation, and I want a class that offers pixel-level access to an image. 
What would be the best way to approach this? 

Alex___

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


NSMenu/NSMenuItem dragdrop

2010-02-11 Thread Adam Warski
Hello,

I've got a NSMenu with NSMenuItem-s and I would like to support dragdrop from 
the menu - so that the users are able to drag the menu items out. However I'm 
having problems attaching the even listener - can it be done? The NSMenuItem 
only supports an action: message.

-- 
Adam Warski
http://www.warski.org
http://www.softwaremill.eu




___

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


Trying to simulate a NSScrollView within a NSView

2010-02-11 Thread fabien.freling
Hi,

I am trying to emulate a scrolling behavior within a NSView.
I am calling scrollRect:by: and as the documentation specifies:

--
Discussion
This method is useful during scrolling or translation of the coordinate system 
to efficiently move as much of the receiver’s rendered image as possible 
without requiring it to be redrawn, following these steps:

• Invoke scrollRect:by: to copy the rendered image.
• Move the view object’s origin or scroll it within its superview.
• Calculate the newly exposed rectangles and invoke either 
setNeedsDisplay: or setNeedsDisplayInRect: to draw them.
You should rarely need to use this method, however. The scrollPoint:, 
scrollRectToVisible:, and autoscroll: methods automatically perform optimized 
scrolling.

(cf. 
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html
 )
--

The scrolling (step 1) looks fine but I don't really get how to set the origin.

My goal is to only redraw the updated areas (top or bottom).
I use Quartz Debug to visualize the updated areas.

I tried using setBounds: but it redraws everything.


A small project can be found here:

http://files.me.com/ffreling/4oa6n8

(I set the NSImageView to an image from my desktop for the example, you can 
remove it or set it to another image if you want)

Any help would be appreciate :)
Thank you.


Best regards,

-- 
Fabien Freling
Software Engineer, Platform team
Nokia, Qt Development Frameworks

___

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


get the list of controls in a NSView

2010-02-11 Thread Jonathan Chacón
Hello everybody,

is there any method to get the list of controls (buttons, labels, splitters, 
etc) of a NSView?


thanks and regards
Jonathan Chacón
Follow me in twitter: 
http://www.twitter.com/jonathanchacon___

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: get the list of controls in a NSView

2010-02-11 Thread Graham Cox

On 12/02/2010, at 3:12 PM, Jonathan Chacón wrote:

 is there any method to get the list of controls (buttons, labels, splitters, 
 etc) of a NSView?


[NSView subViews]

--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/archive%40mail-archive.com

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


Re: What classes have -init?

2010-02-11 Thread Scott Ribe
 My point was that if all Cocoa classes called init
 somewhere in their other initializers (or had a two-step initialization
 similar to what MacApp did), then you could simply override (not call)
 init for simple ivar initialization in a subclass, which would in no way
 interfere with a designated initializer.

I get your point now ;-)

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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: Creating an Application Support folder

2010-02-11 Thread Gideon King
Hi Paul

Firstly, are you using the

NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, 
NSUserDomainMask, YES);

function to find the application support folder?

That would get you the base path, then you can use the 

stringByAppendingPathComponent:

method to add your folder name, then

BOOL isDirectory = NO;
BOOL exists = [[NSFileManager defaultManager] 
fileExistsAtPath:errorReporterPath isDirectory:isDirectory];

and then check whether it exists, and whether it is a directory.

Then you can use methods like:

BOOL created = [[NSFileManager defaultManager] createDirectoryAtPath:path 
withIntermediateDirectories:YES attributes:nil error:error];

to create the necessary folders. Hope this helps.


Gideon

On 11/02/2010, at 1:44 PM, Paul Johnson wrote:

 I'm trying to find a best way to create the Application Support
 folder. I'm rather new at Cocoa so it's taking me a while to do even
 this simple thing. I'm also interested in ensuring my application can
 be localized easily.
 
 I have a function - (NSString *)applicationSupportFolder that
 returns the desired folder name, properly localized. I call this
 function and then use NSFileManager to check for the existence of the
 folder. Because there can be a file (NOT a folder) already bearing the
 folder name, I need to handle that possibility. Everything I've found
 on the internet just ignores this case.
 
 Can anyone recommend what I should do?

___

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: Creating an Application Support folder

2010-02-11 Thread Graham Cox

On 11/02/2010, at 2:44 PM, Paul Johnson wrote:

 I'm trying to find a best way to create the Application Support
 folder. I'm rather new at Cocoa so it's taking me a while to do even
 this simple thing. I'm also interested in ensuring my application can
 be localized easily.
 
 I have a function - (NSString *)applicationSupportFolder that
 returns the desired folder name, properly localized. I call this
 function and then use NSFileManager to check for the existence of the
 folder. Because there can be a file (NOT a folder) already bearing the
 folder name, I need to handle that possibility. Everything I've found
 on the internet just ignores this case.
 
 Can anyone recommend what I should do?


It depends. If there is a file bearing that name - unlikely, really - then what 
do you want to do about it? You could delete it, or you could just choose 
another name for your folder. Either way, NSFileManager has methods to do what 
you want. Renaming you can handle yourself - just keep renaming until you get a 
clear outcome that meets your needs (appending digits is a simple way). 
[NSFileManager fileExistsAtPath:isDirectory:] can tell you whether you're 
looking at a file or folder.

For the rename situation, your -applicationSupportFolder method (why not make 
it a class method?) can do all the work internally to make sure that the folder 
is valid, belongs to you, created if necessary and so on, so clients of it can 
just use the method to work with the folder, safe in the knowledge that there's 
no more to do.

Also, presumably you are returning the name of YOUR unique application support 
folder with the ~Library/Application Support directory. That folder can be 
found using NSApplicationSupportDirectory, then you usually will put your own 
folder inside this. If your folder uses your app's bundle identifier, it will 
almost certainly not collide with anyone else's. However, a much earlier 
discussion on that seemed to indicate that most people use the application 
name, which might not be quite so guaranteed to be unique.

--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/archive%40mail-archive.com

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


Re: What classes have -init?

2010-02-11 Thread Graham Cox

On 12/02/2010, at 1:43 PM, Gordon Apple wrote:

 My point was that if all Cocoa classes called init
 somewhere in their other initializers (or had a two-step initialization
 similar to what MacApp did), then you could simply override (not call)
 init for simple ivar initialization in a subclass, which would in no way
 interfere with a designated initializer.


Except that it would be all too easy to create an infinite loop. A subclass 
might implement -init to call super's designated initializer, which later calls 
-init.

I'm not sure what's complex about overriding the designated initializer - even 
if it has a complex set of parameters, (and most do not) then all you do is 
pass them up to super. Your suggestion would only save a tiny, tiny amount of 
work yet lead to potentially big problems.

--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/archive%40mail-archive.com

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


Re: Creating an Application Support folder

2010-02-11 Thread Fritz Anderson
On 10 Feb 2010, at 9:44 PM, Paul Johnson wrote:

 I have a function - (NSString *)applicationSupportFolder that
 returns the desired folder name, properly localized. I call this
 function and then use NSFileManager to check for the existence of the
 folder. Because there can be a file (NOT a folder) already bearing the
 folder name, I need to handle that possibility. Everything I've found
 on the internet just ignores this case.

You're way overthinking this.

1. Application Support is a standard directory name in Mac OS X, and it's 
always the same name regardless of localization; as with other standard 
directory names, the Finder localizes the name before displaying it.

2. Look for the function NSSearchPathForDirectoriesInDomains(). Pass the 
constant NSApplicationSupportDirectory. Consider which domains you want to 
cover. Heed the warning that the paths the function returns may not describe 
directories that exist yet.

For a cheap example, create a dummy Core Data, non-document project, and crib 
the Application Support algebra from the application delegate.

— 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/archive%40mail-archive.com

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


Replacing model objects using an NSArrayController

2010-02-11 Thread William Peters
Hello everyone,

I'm a bit of a newbie here, but hopefully this question won't be too annoying. 
:-)

My application contains several records displayed to the user in an NSTableView 
bound to an NSArrayController. Because these records are complicated 
(containing around thirty fields), I have implemented an Edit option where the 
user can select one of rows in the table, click the Edit button, and have a new 
window appear displaying all of the fields, radio buttons, numeric values, etc. 
for changing.

I have implemented NSCopying on my data objects. When I go to display the edit 
window, I get a reference to the selected object (myController arrangedObjects 
/ selectionIndexes / objectAtIndex), copy the data into a new object for 
editing ([myObject copy]) and then pass that off to the NSWindowController that 
manages the editing process. I do this so that a Cancel from the editor window 
will not affect the original object.

All of that seems to be straightforward enough.

My question is how to get the new, edited object back into the array controller.

I have implemented all of the KVC methods in the Manager class that supplies 
the data to the NSArrayController, and they are being called for Add and 
Delete. I've also coded a replaceObjectInMyArrayAtIndex:withObject: which I 
would like to be called by the array controller when it swaps in the new object 
for the old one. Although my current code does the same thing with separate 
remove and insert calls (see below), that seems to lead to two undoable 
actions, rather than the one I have coded in 
replaceObjectInMyArrayAtIndex:withObject:

fSrcbook = [selArray objectAtIndex: selItem];
fEditbook = [fSrcbook copy];

// display editing window, etc.

if (returnCode == NSOKButton) {
NSArray * bka = [fArrayController arrangedObjects];

int row = [bka indexOfObjectIdenticalTo: fSrcItem];
[fArrayController removeObject: fSrcItem];
[fArrayController insertObject: fEditItem 
atArrangedObjectIndex: row];
}

(I suppose I could put the remove/insert in an undo edit group, but I'd like to 
keep my undo code out of this method, if possible. No particular reason, except 
that it feels cleaner to me.)

I can't see anything in the NSArrayController class that will help me do the 
replace directly, and nothing else relevant has popped up in my searching for a 
solution. I admit, however, that I am sometimes blind to the obvious, and I 
also may have used inadequate search terms. Still, I highly doubt I'm the first 
person to want to do this, and it just seems like it should be possible to do a 
replace directly.

And I am also wondering if this is the usual way to implement editing a 
complicated object like I am attempting to do.

Any suggestions or clarifications would be greatly appreciated.

Thank you,
Bill

___

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: Creating an Application Support folder

2010-02-11 Thread Graham Cox

On 12/02/2010, at 3:23 PM, Graham Cox wrote:

 That folder can be found using NSApplicationSupportDirectory


Scratch that - this returns the /Library/Application Support, not 
~/Library/Application Support

Gideon's right - use NSSearchPathForDirectoriesInDomains()

--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/archive%40mail-archive.com

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


Re: What classes have -init?

2010-02-11 Thread Charles Srstka
On Feb 11, 2010, at 10:28 PM, Graham Cox wrote:

 On 12/02/2010, at 1:43 PM, Gordon Apple wrote:
 
 My point was that if all Cocoa classes called init
 somewhere in their other initializers (or had a two-step initialization
 similar to what MacApp did), then you could simply override (not call)
 init for simple ivar initialization in a subclass, which would in no way
 interfere with a designated initializer.
 
 
 Except that it would be all too easy to create an infinite loop. A subclass 
 might implement -init to call super's designated initializer, which later 
 calls -init.
 
 I'm not sure what's complex about overriding the designated initializer - 
 even if it has a complex set of parameters, (and most do not) then all you do 
 is pass them up to super. Your suggestion would only save a tiny, tiny amount 
 of work yet lead to potentially big problems.
 
 --Graham

Not really; suppose you want to subclass some class that has two separate init 
methods:

- (id)initWithFoo:(Foo *)foo;
- (id)initWithBar:(Bar *)bar;

and suppose you just want to set some initial internal state, which needs to 
always be set the same way at init time no matter how the object is 
initialized. Which init method do you override? It’s possible that the 
“initWithFoo:” method may look like this:

- (id)initWithFoo:(Foo *)foo
{
return [self initWithBar:[SomeClass convertAFooToABarSomehow:foo]];
}

in which case you’d just need to override initWithBar:. However, what happens 
if it’s actually the other way around, and initWithBar: looks like this:

- (id)initWithBar:(Bar *)bar
{
return [self initWithFoo:[SomeClass convertABarToAFooSomehow:bar]];
}

Knowing which is which requires you to have knowledge of the parent object’s 
code. And what if the implementation of the parent changes over time from one 
of the above scenarios to the other? Clearly the only way to make sure your 
init *always* gets called is to override init, initWithFoo:, *and* 
initWithBar:, and if there are more than just two initializers, this can get 
quite cumbersome. And even then, what happens if the superclass gets updated so 
that a third initializer gets added:

- (id)initWithBaz:(Baz *)baz;

which doesn’t happen to call initWithFoo: *or* initWithBar:? Now your custom 
init won’t get called at all if that initializer is used.

Incidentally, there is just such a class in Cocoa: NSDocument. It provides six 
different init methods:

- (id)init;
- (id)initForURL:(NSURL *)absoluteDocumentURL withContentsOfURL:(NSURL 
*)absoluteDocumentContentsURLofType:(NSString *)typeName error:(NSError 
**)outError;
- (id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
error:(NSError **)outError;
- (id)initWithType:(NSString *)typeName error:(NSError **)outError;
- (id)initWithContentsOfFile:(NSString *)fileName ofType:(NSString *)docType;
- (id)initWithContentsOfURL:(NSURL *)aURL ofType:(NSString *)docType;

Yes, the last two of these are deprecated, but it’s still possible that they 
could get called, so you’d still have to take that into account. Interestingly, 
though, someone at Apple appears to agree with Gordon here, since all of those 
NSDocument initializers actually seem to call -[self init] instead of -[super 
init], with the result that you can in fact just override -init instead of 
having to override all six methods separately (and the NSDocument subclass 
template even includes an -init method, to further encourage this).

Charles___

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: What classes have -init?

2010-02-11 Thread Michael Ash
On Fri, Feb 12, 2010 at 12:07 AM, Charles Srstka
cocoa...@charlessoft.com wrote:
 On Feb 11, 2010, at 10:28 PM, Graham Cox wrote:

 On 12/02/2010, at 1:43 PM, Gordon Apple wrote:

 My point was that if all Cocoa classes called init
 somewhere in their other initializers (or had a two-step initialization
 similar to what MacApp did), then you could simply override (not call)
 init for simple ivar initialization in a subclass, which would in no way
 interfere with a designated initializer.


 Except that it would be all too easy to create an infinite loop. A subclass 
 might implement -init to call super's designated initializer, which later 
 calls -init.

 I'm not sure what's complex about overriding the designated initializer - 
 even if it has a complex set of parameters, (and most do not) then all you 
 do is pass them up to super. Your suggestion would only save a tiny, tiny 
 amount of work yet lead to potentially big problems.

 --Graham

 Not really; suppose you want to subclass some class that has two separate 
 init methods:

 - (id)initWithFoo:(Foo *)foo;
 - (id)initWithBar:(Bar *)bar;

 and suppose you just want to set some initial internal state, which needs to 
 always be set the same way at init time no matter how the object is 
 initialized. Which init method do you override? It’s possible that the 
 “initWithFoo:” method may look like this:

You override the one that's documented to be the designated initializer.

 Incidentally, there is just such a class in Cocoa: NSDocument. It provides 
 six different init methods:

 - (id)init;
 - (id)initForURL:(NSURL *)absoluteDocumentURL withContentsOfURL:(NSURL 
 *)absoluteDocumentContentsURLofType:(NSString *)typeName error:(NSError 
 **)outError;
 - (id)initWithContentsOfURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
 error:(NSError **)outError;
 - (id)initWithType:(NSString *)typeName error:(NSError **)outError;
 - (id)initWithContentsOfFile:(NSString *)fileName ofType:(NSString *)docType;
 - (id)initWithContentsOfURL:(NSURL *)aURL ofType:(NSString *)docType;

 Yes, the last two of these are deprecated, but it’s still possible that they 
 could get called, so you’d still have to take that into account. 
 Interestingly, though, someone at Apple appears to agree with Gordon here, 
 since all of those NSDocument initializers actually seem to call -[self init] 
 instead of -[super init], with the result that you can in fact just override 
 -init instead of having to override all six methods separately (and the 
 NSDocument subclass template even includes an -init method, to further 
 encourage this).

They call -[self init] because NSDocument's designated initializer is
-init. It's not a mystery, you just read the documentation and see
which one is the designated initializer, then override that and call
super.

Mike
___

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: Replacing model objects using an NSArrayController

2010-02-11 Thread Quincey Morris
On Feb 11, 2010, at 20:33, William Peters wrote:

 My application contains several records displayed to the user in an 
 NSTableView bound to an NSArrayController. Because these records are 
 complicated (containing around thirty fields), I have implemented an Edit 
 option where the user can select one of rows in the table, click the Edit 
 button, and have a new window appear displaying all of the fields, radio 
 buttons, numeric values, etc. for changing.
 
 I have implemented NSCopying on my data objects. When I go to display the 
 edit window, I get a reference to the selected object (myController 
 arrangedObjects / selectionIndexes / objectAtIndex), copy the data into a new 
 object for editing ([myObject copy]) and then pass that off to the 
 NSWindowController that manages the editing process. I do this so that a 
 Cancel from the editor window will not affect the original object.
 
 All of that seems to be straightforward enough.
 
 My question is how to get the new, edited object back into the array 
 controller.
 
 I have implemented all of the KVC methods in the Manager class that supplies 
 the data to the NSArrayController, and they are being called for Add and 
 Delete. I've also coded a replaceObjectInMyArrayAtIndex:withObject: which I 
 would like to be called by the array controller when it swaps in the new 
 object for the old one. Although my current code does the same thing with 
 separate remove and insert calls (see below), that seems to lead to two 
 undoable actions, rather than the one I have coded in 
 replaceObjectInMyArrayAtIndex:withObject:
 
   fSrcbook = [selArray objectAtIndex: selItem];
   fEditbook = [fSrcbook copy];
 
   // display editing window, etc.
 
   if (returnCode == NSOKButton) {
   NSArray * bka = [fArrayController arrangedObjects];
 
   int row = [bka indexOfObjectIdenticalTo: fSrcItem];
   [fArrayController removeObject: fSrcItem];
   [fArrayController insertObject: fEditItem 
 atArrangedObjectIndex: row];
   }
 
 (I suppose I could put the remove/insert in an undo edit group, but I'd like 
 to keep my undo code out of this method, if possible. No particular reason, 
 except that it feels cleaner to me.)

There isn't a replace method for an array controller. If you must do it as a 
single operation, then solution would be to fetch the original object at the 
end of editing, update its properties to match the (edited) properties of the 
copy, then discard the now-temporary object copy.

However, your description doesn't completely make sense. There are no objects 
in an array controller. Instead, think of the array controller as a sorted, 
filtered perspective on your underlying data. Normally, the array controller is 
monitoring the underlying data via KVO, so any underlying changes are noticed 
and it adjusts itself accordingly without your writing any code.

You seem to be saying that you've already updated the underlying data model (I 
have implemented all of the KVC methods in the Manager class ...), in which 
case you *don't* want to mess with the array controller directly. Basically, 
there are two approaches to adding, deleting and replacing, when an array 
controller is involved:

1. Update the data model directly and KVO compliantly, and let the array 
controller notice the changes via KVO.

2. Do not update the data model directly, but use the array controller methods 
instead (removeObject:, insertObject:atArrangedObjectIndex:, etc). These 
methods internally cause the data model to be updated.

Pick one. Not both.

Method #1 is the cleanest, because it doesn't introduce the array controller 
(which is really part of your UI glue code) into the data model update, but you 
*must* ensure that the data model change is made KVO compliantly. Typically, 
that means making the changes using a mutableArrayValueForKey: proxy object.

Method #2 is a convenience when you've not built (or have not been able to 
build) a clean MVC design into your app, or when you must work with the 
arrangedObjects order for some reason.

Others will likely disagree with me, but I think that there's something a bit 
smelly about code referring to array controllers. It often indicates a defect 
in the MVC design.


___

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: NSMenu/NSMenuItem dragdrop

2010-02-11 Thread Eric Schlegel

On Feb 11, 2010, at 12:29 AM, Adam Warski wrote:

 Hello,
 
 I've got a NSMenu with NSMenuItem-s and I would like to support dragdrop 
 from the menu - so that the users are able to drag the menu items out. 
 However I'm having problems attaching the even listener - can it be done? The 
 NSMenuItem only supports an action: message.

I don't think that will be possible. The actual display of the menu is handled 
by the Carbon Menu Manager, and it doesn't support the kind of hooks you'd need.

-eric

___

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: What classes have -init?

2010-02-11 Thread Quincey Morris
On Feb 11, 2010, at 21:19, Michael Ash wrote:

 You override the one that's documented to be the designated initializer.

Or, all of the ones that are documented to be the designated initializers, 
since classes are allowed to have multiple designated initializers.

The point I tried to make earlier in this thread is that there's a very simple 
rule:

A class's implementation must cover *every* designated initializer of its 
superclass. Period.

[As a particular case of that rule, every subclass of NSObject must cover 
init.]

Therefore, it is *never* necessary for a client to consider what are the 
designated initializers of the superclass, when considering how to initialize 
an object of a class it wants to instantiate.

[As a matter of implementation detail, a subclass may cover a super 
initializer by overriding it, to modify its behavior or to disallow its use. Or 
it may choose not to override it, effectively making the superclass's 
designated initializer also one of its own designated initializers. But this is 
just an implementation detail. Clients of the class can't tell and don't care, 
beyond knowing what are the documented designated initializers.]


___

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: What classes have -init?

2010-02-11 Thread Graham Cox

On 12/02/2010, at 4:52 PM, Quincey Morris wrote:

 since classes are allowed to have multiple designated initializers.


I don't think that's true. Surely by definition THE designated initializer is 
a single specific method.

The docs state:

The designated initializer is the method in each class that guarantees 
inherited instance variables are initialized (by sending a message to super to 
perform an inherited method). It’s also the method that does most of the work, 
and the one that other initialization methods in the same class invoke. It’s a 
Cocoa convention that the designated initializer is always the method that 
allows the most freedom to determine the character of a new instance (usually 
this is the one with the most arguments, but not always).

Lot's of use of 'the' in this paragraph, no mention of 'a' or 'one of the'.

Is there some other documentation that contradicts this?

--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/archive%40mail-archive.com

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


Re: What classes have -init?

2010-02-11 Thread Kyle Sluder
On Thu, Feb 11, 2010 at 10:00 PM, Graham Cox graham@bigpond.com wrote:
 I don't think that's true. Surely by definition THE designated initializer 
 is a single specific method.

No. 
http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/FrameworkImpl.html

--Kyle Sluder
___

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