Re: automaticallyNotifiesObserversOf

2011-11-04 Thread Quincey Morris
On Nov 4, 2011, at 22:51 , Roland King wrote:

> Then I went and looked in the documentation, couldn't find a reference to it 
> anywhere in iOS, eventually found a note in the 10.5 Leopard release notes 
> that that pattern had been introduced, that's the only documentation I can 
> find on it anywhere. 
> 
> I'm assuming it works on iOS (only have the sim with me here today, not the 
> device and so it's possible they might differ) and is the modern way to turn 
> off observation for single properties, is it? If so I'll file a documentation 
> bug on it.

The pattern is documented in the header file (NSKeyValueObserving.h), so it's 
an officially supported way. Its omission from the regular documentation does 
look like an oversight.


___

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


automaticallyNotifiesObserversOf

2011-11-04 Thread Roland King
I was just turning off automatic KVO for one single property on my class and 
went to implement +(BOOL)automaticallyNotifiesObserversForKey:(NSString*)key. 
When I started to type, Xcode gave me a long list of possibles as it often does 
.. at which point I realized there was one for each named property, named 
automaticallyNotifiesObserversof. I'd not seen that before but 
picked automaticallyNotifiesObserversOfSelectedIndex, which is the property I 
wanted to turn off, made it return NO, and it worked. 

Then I went and looked in the documentation, couldn't find a reference to it 
anywhere in iOS, eventually found a note in the 10.5 Leopard release notes that 
that pattern had been introduced, that's the only documentation I can find on 
it anywhere. 

I'm assuming it works on iOS (only have the sim with me here today, not the 
device and so it's possible they might differ) and is the modern way to turn 
off observation for single properties, is it? If so I'll file a documentation 
bug on it. ___

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: How to get Notification of particular NSUserDefault keys (from the NSGlobalDomain)

2011-11-04 Thread Ken Thomases
On Nov 2, 2011, at 1:47 PM, Travis Griggs wrote:

> I'm trying to create a language binding into the Cocoa environment. And my 
> current problem is how to be able to determine when NSUserDefaults values 
> have changed.

> [...] I just want to know when a user changes a value found in the 
> NSGlobalDomain. In particular at the moment, the result I read with the 
> command line expression
> 
> defaults read NSGlobalDomain AppleShowScrollBars

You can't.  There's no general means to know when other processes change 
defaults, especially in domains other than your app's.

However, there's a very good chance that System Preferences sends out a 
distributed notification when it changes that setting.  The exact name of that 
notification is an implementation detail which could change at any time and 
relying on it in a shipping application is inviting trouble.  I don't know for 
sure that there is such a notification nor what its name might, but you can 
write a program which monitors _all_ distributed notifications and find out for 
yourself.  Just watch what happens when you toggle that System Preferences 
setting.

NSDistributedNotificationCenter* center = 
[NSDistributedNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(observeDistributed:) 
name:nil object:nil];

- (void)observeDistributed:(NSNotification*)notification
{
NSLog(@"NSDistributedNotificationCenter: %@\n%@", [notification name], 
notification);
}

Regards,
Ken

___

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: Printing image represented by multiple tiles using Cocoa

2011-11-04 Thread Ken Thomases
On Oct 23, 2011, at 6:26 AM, Rahul Kesharwani wrote:

> I have a application that prints a image of a page of document on paper. The 
> image is usually tiled and is provided as a set of 4 tiles representing the 
> entire image. Till now this is being done using Carbon printing APIs .

The APIs you list below are not Carbon.  They are C APIs rather than 
Objective-C, but not all C APIs are Carbon.  Both Carbon and Cocoa are 
windowing and event frameworks built on top of other frameworks, some of which 
have a C interface and others of which have Objective-C interface.  Core 
Printing and Core Graphics, the two frameworks you're using, are below both 
Carbon and Cocoa.

My point is: there may be no need to replace your existing code.  If you're 
trying to move away from Carbon, well, already done!

> The set of functions calls and their order for printing a document is :
> 
> 1.PMSessionBeginCGDocumentNoDialog(); //Called at he beginning of a 
> document
>   
> 2.Following calls at the beginning of each page
> 
>   PMSessionBeginPageNoDialog();
> 
>   //Get the current graphics context for drawing the page
>   PMSessionGetCGGraphicsContex(printSession , &mPrintContext);
>   
>   //Some Calculations based on paper rect and imageable area
> 
>   // move the origin of CG from that of paper device to imageable area 
> based on above calculation
>   CGContextTranslateCTM();
> 
> 3.While there are more tiles
>   //Copy image tile(img) to target area(tileRect) on the print 
> device.
>   CGContextDrawImage(mPrintContext, tileRect, img);
> 
> 4.PMSessionEndPageNoDialog(); //At end of each page
> 
> 5.Repeat steps 2-4 for other pages.
> 
> 6.PMSessionEndDocumentNoDialog()  //Called at the end of document
> 
> 
> I need to implement the above steps using Cocoa APIs. Any suggestions how to 
> implement this entire workflow using Cocoa. I have my NSPrintInfo instance 
> set up. I know I have to create an instance of NSPrintOperation and 
> initialize it with a NSView representing the page I want to print. I am stuck 
> at step 3, i.e drawing 4 tiles of the image to create a single image 
> representing a page and then create a NSView out of it.

You don't create an image and then "create a NSView out of it".  An NSView is 
an active thing.  It draws itself.  You create a subclass of NSView and in its 
-drawRect: method, you do the calculations, transforms, and drawing of the 
tiles.  (No consolidated image necessary.)  The one view represents the content 
of the entire document, not just a page.  Within the -drawRect: method, you 
obtain the tiles to draw in the same way as you would in your existing code.

Since you want to print this document across multiple pages, you'll presumably 
want to implement the pagination methods, too.  See Printing Programming Topics 
for Cocoa: Pagination 

 and Providing a Custom Pagination Scheme 
.

If it helps you to think about it, Cocoa will do step 1 and the first part of 
step 2 for you.  Prior to calling your view's -drawRect: method, it will have 
begun a page and set up the thread's active graphics context for that page.  
Your -drawRect: method does the latter half of step 2 (the computations and, 
optionally, tweaking the configuration of the graphics context) and step 3 (the 
actual drawing of the document content).  Cocoa then does steps 4 and 5 (the 
looping back to step 2 for the subsequent pages), then step 6.

Conceptually, your -drawRect: method draws the entirety of the view, which is 
the entirety of the document, each time it is invoked, and the graphics context 
will have been translated and clipped so that only one page worth of content is 
actually printed each time.  To be more efficient, though, you'd only draw 
those tiles corresponding to the passed-in rect, which would correspond to a 
single page due to your pagination scheme.

Regards,
Ken

___

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


Moderator - List web back on line

2011-11-04 Thread Scott Anguish
I wanted to drop a quick note to the list, the web interface is back online.

The biggest impact on many of you is that moderated messages can now be 
approved. I just went through a approved all those in the queue. Some of them 
might have already been solved, but better late than sorry.

Hopefully things will be stable for a long time to come.

Thanks for your understanding.

Moderator *scott=[CocoaDev moderator];

___

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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Roland King
That looks about right. I'm still messing about with non SQLite stores but what 
I'm assuming happens when you set the Ubiquitous* keys in the SQLite store 
options and migrate, that creates the log files you need for iCloud synching. I 
really need to go write a test app and mess with this stuff until I grok it 
properly. 

Where in your code are you actually moving the whole thing to iCloud? 

Remember also that your SQLite store in the iCloud version is supposed to be 
somewhere which isn't synched. The recommendation is to put it in a .nosync 
subdirectory in the ubiquity container (although on iOS I've wondered if just 
keeping it locally in a non-sync directory in documents would work fine too). 

As to your question about broken sync. Can't help you there more than to tell 
you I've seen a number of other messages about that. Some people for testing 
are changing the directory name (from test1 to test2 etc) and there are also 
suggestions that you run something to clean out the ubiquitous store, like this

 BOOL cleanUbiquitousFolder = YES;
 if (cleanUbiquitousFolder) 
 {
  NSFileManager *fileManager = [NSFileManager defaultManager];
  [fileManager removeItemAtURL:[fileManager 
URLForUbiquityContainerIdentifier:nil] error:nil];

  return NO;
 }

I'm pleased you got this going so quickly, I struggled to get my simple 
document based app to work with a dumb binary store in the cloud and figured 
SQLite would add another layer of pain. 


On Nov 5, 2011, at 12:24 AM, Martin Hewitson wrote:

> 
> On 4, Nov, 2011, at 03:06 PM, Roland King wrote:
> 
>> 
>> On Nov 4, 2011, at 1:41 PM, Martin Hewitson wrote:
>> 
>>> 
>>> On 4, Nov, 2011, at 02:01 AM, Roland King wrote:
>>> 
 
 
 
 
> So, can I conclude from this that iCloud and core-data only works with 
> SQL store? The WWDC video hints at this, but was not explicit.
> 
 
 Not so. I have a core data app running using icloud and an XML store. This 
 is ios by the way and the store is not incremental, it's just being 
 treated as a blob which is fully synced each time but it's small so that's 
 ok. 
 
 Definitely if you want the incremental log style store you have to use SQL 
 but in general core data in iCloud will let you use whatever you like.
>>> 
>>> I hadn't realised that I had made a choice. How does one choose an 
>>> incremental store as opposed to a blob? Any pointers how you got your 
>>> core-data iCloud app working would be greatly appreciated!
>> 
>> Those two keys you add when you open the persistent store, 
>> NSPersistentStoreUbiquitousContentNameKey and 
>> NSPersistentStoreUbiquitousContentURLKey are the ones which tell Core Data 
>> you're using the log file based core data (only available with SQLite). So 
>> with that store, the actual SQLite database isn't in the cloud, it's kept 
>> local, but a log file directory is created which is in the cloud and deltas 
>> are synched up there. The idea is that each client just brings down the log 
>> files and updates the database at a record level. Those keys only mean 
>> anything with the SQLite store, which may be why you're having issues with 
>> migration. I don't use any of those keys, I just have my store as a local 
>> file which is synched wholesale. 
>> 
>> For your original mail, you want to migrate to SQLLite and then also migrate 
>> to iCloud. I don't know if you can do that easily in one step. If I were 
>> looking at this I would probably think of creating a new SQLLite store for 
>> the migration, empty, opening the old local XML store and then migrating the 
>> objects over with code. Whether you choose to make the new SQLite store 
>> local and then migrate it up to iCloud or make it in the cloud and then 
>> update it is a question I don't have a good answer to, I'm still a little 
>> confused by how the initial log files get magically created when you migrate 
>> a document to iCloud, I'm definitely missing a piece of information 
>> somewhere. 
> 
> I think I've achieved this migration step with code like this:
> 
> NSURL *oldURL = [NSURL fileURLWithPath:[applicationSupportDirectory 
> stringByAppendingPathComponent:oldStoreName]];
> NSURL *newURL = [NSURL fileURLWithPath:[applicationSupportDirectory 
> stringByAppendingPathComponent:storeName]];
> 
> persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
> initWithManagedObjectModel:mom];
> if ([fileManager fileExistsAtPath:[oldURL path]]) {
>   NSError *error = nil;
>   NSPersistentStore *store = [persistentStoreCoordinator 
> addPersistentStoreWithType:NSXMLStoreType
>   
> configuration:nil
>   
>   URL:oldURL
> 
> options:options
>

NSNumberFormatter erases invalid values on Lion with 10.6 SDK

2011-11-04 Thread George Nachman
I just moved to XCode 4, from the Mac OS 10.5 SDK to the 10.6 SDK, and
from Snow Leopard to Lion. A behavior that changed is that entering
invalid text into an NSTextField with an NSNumberFormatter causes the
entire field's contents to be erased rather than disallowing the bogus
character from being added.

In my example, I have an NSNumberFormatter with a min value of 1, a
max value of 1000, isLenient, and localization on. Enter a value
like "123" and it's ok. Type a letter "x" and the entire value is
erased.

The erasure occurs when the field's stringValue or intValue is accessed.

The text field and number formatter are defined in a XIB file. I would
like invalid input to be prevented or at worst tolerated and ignored,
but erasing the whole value is really not OK.

Another strange thing that happens is that when entering a value
larger than 10,000 the entire value is erased. The text field's
-stringValue in the delgate's -controlTextDidChange: returns
@"10," and immediately after being evaluated is changed to an
empty string.

Is this behavior intentional? Can I get the old behavior back somehow?

Thanks,
George
___

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


Issue with IOHIDDeviceOpen and Exclusive Access

2011-11-04 Thread CoGe - Tamas Nagy
Hey list,

i have a little problem with IOHIDDeviceOpen and Exclusive Access - when i call 
this method kIOHIDOptionsTypeSeizeDevice option, it returns kIOReturnSuccess, 
but i get no exlusive access. However, it works with the device manager, but i 
just need to have exclusive access for one specific device. I followed up the 
steps of TN2187: 
http://developer.apple.com/library/mac/#technotes/tn2187/_index.html

Is this a bug? If it, is there a workaround with it? I'm on 10.6.8 yet.  

Thanks a lot,

Tamas Nagy
-
CoGe VJ Software
http://cogevj.hu
i...@cogevj.hu



___

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


How to get Notification of particular NSUserDefault keys (from the NSGlobalDomain)

2011-11-04 Thread Travis Griggs
I'm trying to create a language binding into the Cocoa environment. And my 
current problem is how to be able to determine when NSUserDefaults values have 
changed. I've read through all of these a couple of times:

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/Reference/Reference.html

http://stackoverflow.com/questions/3166563/how-to-receive-nsuserdefaultsdidchangenotification-iphone
8:37 AM
http://stackoverflow.com/questions/1141388/cocoa-notification-on-nsuserdefaults-value-change

But I am unable to get a simple cocoa program that does this. I don't care if 
it's done with key-value stuff, or not, I just want to know when a user changes 
a value found in the NSGlobalDomain. In particular at the moment, the result I 
read with the command line expression

defaults read NSGlobalDomain AppleShowScrollBars

If anyone can tell me succinctly, what message I send to what, to get 
notification set up to be notified when that setting changes, I would be very 
very grateful. I've beat my head against this for a couple of days :(

--
Travis Griggs
Objologist
Simplicity is the Ultimate Sophistication -- Leonardo da Vinci

___

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: Sandbox issues

2011-11-04 Thread Sam Rowlands
Depending on what you are doing with iPhoto, could it be accomplished with 
Apple Scripts? If so, there is a temporary entitlement that will allow you to 
send Apple Scripts to a specific application such as iPhoto.

On Nov 1, 2011, at 2:06 AM, cocoa-dev-requ...@lists.apple.com wrote:

>> This is prohibited under sandboxing. Read "Accessing Preferences of
>> Other Apps" in the App Sandbox Design Guide:
>> http://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/DesigningYourSandbox/DesigningYourSandbox.html#//apple_ref/doc/uid/TP40011183-CH4-SW12

have a great week.

Sam Rowlands

___

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: Write to file Entitlement

2011-11-04 Thread Sam Rowlands
IIRC: Take a look at Temporary entitlements, there is one that will enable your 
application to read/write to the entire user area. The bit I don't understand 
is why it's marked as a temporary entitlement.


Thanks for supporting our software and have a great week.

Sam Rowlands
s...@ohanaware.com

http://www.ohanaware.com - Fun Photos, HDRtist Pro & some cool free apps.

On Nov 1, 2011, at 2:06 AM, cocoa-dev-requ...@lists.apple.com wrote:

> Date: Mon, 31 Oct 2011 08:10:57 -0700
> From: James Merkel 
> Subject: Re: Write to file Entitlement
> To: Gideon King 
> Cc: cocoa-dev cocoa-dev 
> Message-ID: <19bb41e9-f08b-4795-8b99-3aa37340c...@mac.com>
> Content-Type: text/plain; CHARSET=US-ASCII
> 
> That will completely break my app.
> Off the top of my head, I don't know how I would change things to conform to 
> that regime.
> I update files in a batch mode.
> 
> Jim Merkel

___

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


Printing multiple images each on a separate page using single NSPrintOperation

2011-11-04 Thread Rahul Kesharwani
Hi

I have a application that intends to print raster image of each page of a 
document using NSPrintOperation. I am able to create a NSImage of a single page 
and print it using NSPrintOperation as follows

-void printPage: (NSImage)nsImage
{
NSImageView *nsImageView = [[NSImageView alloc] init];
NSSize imageSize = [nsImage size];
[nsImageView setImage: (NSImage *)nsImage];
[nsImageView setFrame:NSMakeRect(0, 0, imageSize.width, 
imageSize.height)];
[nsImageView setImageScaling:NSScaleToFit];

NSPrintOperation *mNSPrintOperation = [NSPrintOperation 
printOperationWithView: (NSView *)nsImageView];

NSPrintInfo *currentNSPrintInfo = [NSPrintInfo sharedPrintInfo];
[currentNSPrintInfo setHorizontalPagination:NSFitPagination];
[currentNSPrintInfo setVerticalPagination:NSFitPagination];

[mNSPrintOperation setPrintInfo:currentNSPrintInfo];
[mNSPrintOperation setShowsPrintPanel:NO];
[mNSPrintOperation setShowsProgressPanel:YES];

[mNSPrintOperation runOperation];
}

Now when I have multiple pages to print, I would like to print all of them 
using a single NSPrintOperation. So basically, I would like to insert 
NSImage/NSImageView of each page as a separate page into a single NSView and 
use this NSView to print finally using NSPrintOperation. The reason I want to 
print it using single NSPrintOperation is that I want to get the print progress 
bar that shows the current page being printed. Otherwise, I could have created 
a separate NSPrintOperation for each NSImageView and print using it.

Any help would be greatly appreciated

Thanks & Regards
Rahul
___

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


Funky errors using MPMoviePlayerViewController

2011-11-04 Thread Gene Crucean
Can someone simplify what these errors mean? I get this when I click a
button to play a video (download over internet on demand style). And
possibly related... a problem I'm having is that my video plays with no
audio. In fact the audio volume bar goes away completely on load.

Any pointers are appreciated.



~~>>SponViewController :sponButton: 2011-10-26 12:52:04.212
myapp[2692:12e03] Error loading
/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:
dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.222 myapp[2692:12e03] Error loading
/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:
dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.258 myapp[2692:12e03] Error loading
/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:
dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.269 myapp[2692:12e03] Error loading
/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:
dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.293 myapp[2692:12e03] Error loading
/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:
dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.307 myapp[2692:12e03] Error loading
/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:
dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.340 myapp[2692:12e03] Error loading
/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:
dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn,
262): Symbol not found: ___CFObjCIsCollectable Referenced from:
/System/Library/Frameworks/Security.framework/Versions/A/Security Expected
in:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

2011-10-26 12:52:04.351

Printing image represented by multiple tiles using Cocoa

2011-11-04 Thread Rahul Kesharwani
Hi

I have a application that prints a image of a page of document on paper. The 
image is usually tiled and is provided as a set of 4 tiles representing the 
entire image. Till now this is being done using Carbon printing APIs . The set 
of functions calls and their order for printing a document is :


1.  PMSessionBeginCGDocumentNoDialog(); //Called at he beginning of a 
document

2.  Following calls at the beginning of each page

PMSessionBeginPageNoDialog();

//Get the current graphics context for drawing the page
PMSessionGetCGGraphicsContex(printSession , &mPrintContext);

//Some Calculations based on paper rect and imageable area

// move the origin of CG from that of paper device to imageable area 
based on above calculation
CGContextTranslateCTM();

3.  While there are more tiles
//Copy image tile(img) to target area(tileRect) on the print 
device.
CGContextDrawImage(mPrintContext, tileRect, img);

4.  PMSessionEndPageNoDialog(); //At end of each page

5.  Repeat steps 2-4 for other pages.

6.  PMSessionEndDocumentNoDialog()  //Called at the end of document


I need to implement the above steps using Cocoa APIs. Any suggestions how to 
implement this entire workflow using Cocoa. I have my NSPrintInfo instance set 
up. I know I have to create an instance of NSPrintOperation and initialize it 
with a NSView representing the page I want to print. I am stuck at step 3, i.e 
drawing 4 tiles of the image to create a single image representing a page and 
then create a NSView out of it.

So my problem statement is: How to combine multiple image tiles (each being a 
CGImageRef) into a single image representing a page and print it using 
NSPrintOperation. Once this is achieved, how to print multiple such pages of a 
document using NSPrintOperation?

Thanks & Regards
Rahul Kesharwani___

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

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

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

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


Re: Why does ARC retain method arguments even with full optimization?

2011-11-04 Thread Charles Srstka
On Nov 4, 2011, at 10:32 PM, Preston Sumner wrote:

> Not if the functions end up sending the message through the runtime anyway, 
> which is apparently the case.___

Since part of the ARC spec requires objects to respond to -retain, -release, 
and -autorelease 
(http://clang.llvm.org/docs/AutomaticReferenceCounting.html#objects.retains), 
this is expected. However, there are still speed gains. For example, in the 
example posted earlier:

Foo *foo = [self foo];
[self doSomethingElse];
[foo bar];

the -foo method will in many cases return an autoreleased object. Under normal 
memory management, non-ARC, this would end up looking like this:

- (Foo *)foo {
return [[fooIvar retain] autorelease];
}

- (void)bar {
Foo *foo = [self foo];
[self doSomethingElse];
[foo bar];
}

Upon calling the accessor, retain and autorelease are sent to foo. Sometime 
later on, foo is sent a release when the autorelease pool is drained, for a 
total of three message sends.

The way I understand it with ARC, though, is that it can peek at the stack to 
see what will happen to a pointer after it’s returned, and cut out some of the 
unnecessary message sends, so while it’s actually generating something like 
this:

- (Foo *)foo {
return objc_retainAutoreleaseReturnValue(fooIvar);
}

- (void)bar {
Foo *foo = objc_retainAutoreleasedReturnValue([self foo]);
[self doSomethingElse];
[foo bar];
objc_release(foo);
}

in practice, it’s effectively doing something equivalent to this:

- (Foo *)foo {
return [fooIvar retain];
}

- (void)bar {
Foo *foo = [self foo]; // -autorelease and -retain cancel each other 
out here, so they’re both eliminated at runtime
[self doSomethingElse];
[foo bar];
[foo release];
}

The messages actually sent to foo are retain and release, a total of two 
message sends; plus, the autorelease pool doesn’t get involved. That’s a win if 
you ask me.

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: Why does ARC retain method arguments even with full optimization?

2011-11-04 Thread Preston Sumner
On Nov 4, 2011, at 9:29 PM, Louis Romero wrote:

> Don't you bypass an objc_msgSend, then?
> Please tell me if I'm wrong.
> -- 
> Louis

Not if the functions end up sending the message through the runtime anyway, 
which is apparently the case.___

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: Allocating too much memory kills my App rather than returning NULL

2011-11-04 Thread Igor Mozolevsky
On 5 November 2011 02:38, Dave Zarzycki  wrote:
> You're tripping across a fundamental aspect of how virtual memory works.

[snip]

Also, watch what you're *really* allocating:

% cat ./malloc_test.c
#include 
#include 
#include 


int main(int c, char **v) {
  const size_t size[] = {2, 33, 1025, 4097, 1024*1024+1, 0};

  for(int i = 0; size[i] != 0; i++) {

unsigned char *ptr = calloc(1, size[i]);

if(!ptr) {
  abort();
}

fprintf(stderr,
"Allocated `%zu' bytes at %p\n"
"\treally allocated: %zu\n"
"\tsuggested good size: %zu\n",
size[i],
ptr,
malloc_size(ptr),
malloc_good_size(size[i]));
free(ptr);
  }

  return 0;
}
% cc --std=c99 -o malloc_test malloc_test.c
% ./malloc_test
Allocated `2' bytes at 0x100100080
really allocated: 16
suggested good size: 16
Allocated `33' bytes at 0x100100090
really allocated: 48
suggested good size: 48
Allocated `1025' bytes at 0x10080
really allocated: 1536
suggested good size: 1536
Allocated `4097' bytes at 0x100800600
really allocated: 4608
suggested good size: 4608
Allocated `1048577' bytes at 0x10020
really allocated: 1052672
suggested good size: 1052672



Cheers,

--
Igor :-)
___

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: Allocating too much memory kills my App rather than returning NULL

2011-11-04 Thread Dave Zarzycki
You're tripping across a fundamental aspect of how virtual memory works. For 
example: what do you expect will happen if you do this on an iOS device (none 
of which have more than 512*1024*1024 bytes of memory)?

void *x = malloc(1024*1024*1024);
assert(x);

The answer depends on whether a given operating system overcommits memory or 
not. In practice, all general purpose operating systems overcommit memory. This 
is due to this pattern:

char *x = malloc(BIG_BUFFER);
example(x, BIG_BUFFER, ...); // use a small part of BIG_BUFFER, but not 
all of it
free(x);

Overcommitting memory means that the virtual address space has been allocated 
for the memory, but not the actual physical memory to back the allocation. The 
actual physical memory is allocated on demand (4KB at a time) as parts of the 
buffer are read or written to for the first time. In other words, given 
prevailing design patterns, the ability to overcommit memory leads to better 
memory utilization, but at the risk that code may crash when attempting to 
actually use 100% of the "allocated" memory.

The way one reconciles this design tradeoff is by listening to the 
notifications that you refer to. This is actually a great pattern, because it 
is more multitasking friendly when multiple processes are competing for RAM.

davez


On Nov 4, 2011, at 6:40 PM, Don Quixote de la Mancha wrote:

> My iOS App Warp Life is an implementation of the Cellular Automaton
> known as Conway's Game of Life:
> 
>   http://www.dulcineatech.com/life/
> 
> The game takes place on a square grid.  Each square is known as a
> "Cell", with the Dead or Alive state of the Cell being indicated by a
> single bit to conserve memory.
> 
> I store the grid as an array-of-arrays rather than a two dimensional
> array.  That is, I have an array of pointers which has the same number
> of elements as there are rows.  Each row is array of unsigned longs,
> with the number of elements being the number of columns divided by
> thirty-two.
> 
> The user can set the size of the grid in my Settings view.  I attempt
> but fail to allow the user to make the grid as large as the available
> memory will allow.
> 
> My code checks that calloc() returns valid pointers for each
> allocation attempted when creating a new grid.  If all the allocations
> succeed, I copy the data in the old grid into the center of the new
> one, then free() each array in the old grid.
> 
> If calloc() ever returns NULL while attempting to allocate the new
> grid, I back out all of the successful allocations by passing each
> array pointer to free().  Then I display an alert to the user to
> advise them that there is not enough memory for their desired grid
> size, and suggest trying a smaller one.
> 
> This all works great when I run it in the Simulator with Xcode 4.2.
> I'm pretty sure I've had this work in the Simulator in several
> previous versions of Xcode.
> 
> In iOS 3.1.2 on a first-generation iPhone, 3.2 on a first-gen iPad and
> 4.3 on an iPhone 4, my App terminates before calloc() ever returns
> NULL!
> 
> I have not yet tried with iOS 5 or the 5.0.1 betas, but even if this
> is an iOS bug that has been fixed, I would much rather work around it
> as I do not want to require my users to upgrade their firmware just to
> be able to run my App.  Other than this one problem everything in my
> App works great all the way back to iOS 3.1.2.
> 
> Even though I feel it should not be necessary to check for Cocoa Touch
> memory warnings if I am freeing all my arrays when calloc() fails, I
> did try adding an application delegate as well as creating my own base
> class for all my view controllers that do implement the memory warning
> methods.  These implementations set a global flag that indicates it is
> not safe to allocate any more memory.  Then instead of calling
> calloc() directly, I call a custom allocation function that returns
> NULL if that flag is ever set.  Only after freeing all the arrays do I
> reset the flag to enable further allocations.
> 
> I set breakpoints at each of the memory warning methods, but my
> breakpoints are never hit.  I also tried breaking on Objective-C
> exceptions but no exceptions are thrown.  After my App terminates, the
> debugger GUI indicates that my app is paused - GDB doesn't seem to
> know that my App has actually been killed.  I have to press the Stop
> button in Xcode to let GDB know that it's time to quit.
> 
> If y'all think this is an as-yet-unreported bug in the iOS I will be
> happy to file a report, but I would be even happier if someone could
> suggest a workaround.  I've been beating my head against this for a
> couple days now.
> 
> Thanks!
> 
> Don Quixote
> -- 
> Don Quixote de la Mancha
> Dulcinea Technologies Corporation
> Software of Elegance and Beauty
> http://www.dulcineatech.com
> quix...@dulcineatech.com
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 

Allocating too much memory kills my App rather than returning NULL

2011-11-04 Thread Don Quixote de la Mancha
My iOS App Warp Life is an implementation of the Cellular Automaton
known as Conway's Game of Life:

   http://www.dulcineatech.com/life/

The game takes place on a square grid.  Each square is known as a
"Cell", with the Dead or Alive state of the Cell being indicated by a
single bit to conserve memory.

I store the grid as an array-of-arrays rather than a two dimensional
array.  That is, I have an array of pointers which has the same number
of elements as there are rows.  Each row is array of unsigned longs,
with the number of elements being the number of columns divided by
thirty-two.

The user can set the size of the grid in my Settings view.  I attempt
but fail to allow the user to make the grid as large as the available
memory will allow.

My code checks that calloc() returns valid pointers for each
allocation attempted when creating a new grid.  If all the allocations
succeed, I copy the data in the old grid into the center of the new
one, then free() each array in the old grid.

If calloc() ever returns NULL while attempting to allocate the new
grid, I back out all of the successful allocations by passing each
array pointer to free().  Then I display an alert to the user to
advise them that there is not enough memory for their desired grid
size, and suggest trying a smaller one.

This all works great when I run it in the Simulator with Xcode 4.2.
I'm pretty sure I've had this work in the Simulator in several
previous versions of Xcode.

In iOS 3.1.2 on a first-generation iPhone, 3.2 on a first-gen iPad and
4.3 on an iPhone 4, my App terminates before calloc() ever returns
NULL!

I have not yet tried with iOS 5 or the 5.0.1 betas, but even if this
is an iOS bug that has been fixed, I would much rather work around it
as I do not want to require my users to upgrade their firmware just to
be able to run my App.  Other than this one problem everything in my
App works great all the way back to iOS 3.1.2.

Even though I feel it should not be necessary to check for Cocoa Touch
memory warnings if I am freeing all my arrays when calloc() fails, I
did try adding an application delegate as well as creating my own base
class for all my view controllers that do implement the memory warning
methods.  These implementations set a global flag that indicates it is
not safe to allocate any more memory.  Then instead of calling
calloc() directly, I call a custom allocation function that returns
NULL if that flag is ever set.  Only after freeing all the arrays do I
reset the flag to enable further allocations.

I set breakpoints at each of the memory warning methods, but my
breakpoints are never hit.  I also tried breaking on Objective-C
exceptions but no exceptions are thrown.  After my App terminates, the
debugger GUI indicates that my app is paused - GDB doesn't seem to
know that my App has actually been killed.  I have to press the Stop
button in Xcode to let GDB know that it's time to quit.

If y'all think this is an as-yet-unreported bug in the iOS I will be
happy to file a report, but I would be even happier if someone could
suggest a workaround.  I've been beating my head against this for a
couple days now.

Thanks!

Don Quixote
-- 
Don Quixote de la Mancha
Dulcinea Technologies Corporation
Software of Elegance and Beauty
http://www.dulcineatech.com
quix...@dulcineatech.com
___

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

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

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

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


Re: Core Data loading faulted object?

2011-11-04 Thread Rick Mann

On Nov 4, 2011, at 11:33 , Mike Abdullah wrote:

> 
> On 4 Nov 2011, at 00:29, Rick Mann wrote:
> 
>> Mike,
>> 
>> Did you have any speculation as to why this might be happening?
> 
> Not especially, I mostly asked since it's an important detail which might 
> prompt others.

I think I'm seeing that Core Data frequently loads items in a faulted state. 
So, something else is going wrong in this case.

> 
> Have you any delete rules which are set to "No action"?
> 

___

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

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

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

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


Re: [Q] loadView doesn't return?

2011-11-04 Thread JongAm Park
It turned out that it didn't like to instantiate an NSViewControl class in its 
xib.
So, instead, I created it in the code and it made "loadView" returns.

However, I still have some problems.

Although audio is played, video is not played.

So, I changed its view class for setting player like this ( by refering 
ViewController sample codes )

- (void) setPlayer:(AVPlayer *)player
{

//  [(AVPlayerLayer *)[self layer] setPlayer:player];

AVPlayerLayer *playerLayer = [AVPlayerLayer 
playerLayerWithPlayer:player];
[playerLayer setFrame:[self.layer bounds]];
[playerLayer setAutoresizingMask:(kCALayerWidthSizable | 
kCALayerHeightSizable)];
[self setLayer:playerLayer];
}

However, it still doesn't display any video frame.

Any ideas?

FYI, This is how it looks in ViewController sample codes :
Thank you.

- (void)awakeFromNib
{
NSString* moviePathStr = [[NSBundle mainBundle] pathForResource:@"adam" 
ofType:@"mov"];

player = [[AVPlayer alloc] init];
AVURLAsset *file = [AVURLAsset assetWithURL:[NSURL 
fileURLWithPath:moviePathStr isDirectory:NO]];

[file loadValuesAsynchronouslyForKeys:nil completionHandler:^(void) {

// The asset invokes its completion handler on an arbitrary 
queue when loading is complete.
// Because we want to access our AVPlayer in our ensuing 
set-up, we must dispatch our handler to the main queue.
dispatch_async(dispatch_get_main_queue(), ^(void) {

// Create an AVPlayerLayer and add it to the player 
view if there is video, but hide it until it's ready for display
AVPlayerLayer *newPlayerLayer = [AVPlayerLayer 
playerLayerWithPlayer:player];
[newPlayerLayer setFrame:[[self.view layer] bounds]];
[newPlayerLayer setAutoresizingMask:kCALayerWidthSizable | 
kCALayerHeightSizable];
[[self.view layer] addSublayer:newPlayerLayer];

// Create a new AVPlayerItem and make it our player's current item.
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:file];
[player replaceCurrentItemWithPlayerItem:playerItem];

playingForward = YES;
[[NSNotificationCenter defaultCenter] 
addObserverForName:AVPlayerItemDidPlayToEndTimeNotification object:playerItem 
queue:nil usingBlock:^(NSNotification *note) {
if(playingForward) {
[player 
seekToTime:CMTimeMultiplyByFloat64(playerItem.duration, 0.99f)];
[player play];
player.rate = -1;
playingForward = NO;
} else {
[player seekToTime:kCMTimeZero];
[player play];
player.rate = 1;
playingForward = YES;
}
}];

[player play];
[player release];
});

}];
}



On Nov 4, 2011, at 9:46 AM, JongAm Park wrote:

> 
> Hello,
> 
> I tried to use AV Foundation's playback capability.
> So, by following AV Foundation Programming Guideline, it wrote codes for Mac. 
> ( The document is written for iOS. )
> Also, I looked up "View Controller" sample codes and "AnimatedTableView".
> 
> What is strange is that it doesn't return after loadView was called in my 
> testing project, although it does in those sample codes.
> I didn't find any semantic difference yet.
> 
> This is from my sample codes :
> 
> An app delegate class :
> 
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
>   // Insert code here to initialize your application
>   
>   NSLog( @"AppDelegate >> applicationDidFinishLaunching" );   
>   
>   [_placeholderView addSubview:_viewController.view]; => calls loadView 
> of a child class of NSViewController
>   [_viewController.view setFrame:_placeholderView.frame];
>   [_viewController setRepresentedObject:[NSNumber 
> numberWithUnsignedLong:[[_viewController.view subviews] count]]];
> }
> 
> 
> The child class of NSViewController
> 
> - (void)loadView
> {
>   [self viewWillLoad];
>   [super loadView]; <= doesn't return
>   [self viewDidLoad];
> }
> 
> Does anyone know why the loadView doesn't return?
> Can you spare me your idea?
> 
> Thank you.
> 
> 

___

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: How to detect clicks outside of modal window?

2011-11-04 Thread David Riggle
Subclass NSApplication and override this method:

- (NSEvent *)nextEventMatchingMask:(NSUInteger)mask untilDate:(NSDate 
*)expiration inMode:(NSString *)mode dequeue:(BOOL)deqFlag
{
NSEvent *event = [super nextEventMatchingMask:mask untilDate:expiration 
inMode:mode dequeue:deqFlag];
NSEventType type = [event type];// 0 if event is nil
if (type == NSLeftMouseDown || type == NSRightMouseDown) {
if (m_popoverModalWindow != nil && [event window] != 
m_popoverModalWindow) {
[self stopModalWithCode:NSCancelButton];
event = nil;
}
}
return event;
}

Then add this method, which you call instead of -runModalForWindow:

- (NSInteger)runPopoverModalForWindow:(NSWindow *)theWindow
{
m_popoverModalWindow = theWindow;
NSInteger result = [super runModalForWindow:theWindow];
m_popoverModalWindow = nil;
return result;
}


___

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 loading faulted object?

2011-11-04 Thread Mike Abdullah

On 4 Nov 2011, at 00:29, Rick Mann wrote:

> Mike,
> 
> Did you have any speculation as to why this might be happening?

Not especially, I mostly asked since it's an important detail which might 
prompt others.

Have you any delete rules which are set to "No action"?

___

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


[Q] loadView doesn't return?

2011-11-04 Thread JongAm Park

Hello,

I tried to use AV Foundation's playback capability.
So, by following AV Foundation Programming Guideline, it wrote codes for Mac. ( 
The document is written for iOS. )
Also, I looked up "View Controller" sample codes and "AnimatedTableView".

What is strange is that it doesn't return after loadView was called in my 
testing project, although it does in those sample codes.
I didn't find any semantic difference yet.

This is from my sample codes :

An app delegate class :

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application

NSLog( @"AppDelegate >> applicationDidFinishLaunching" );   

[_placeholderView addSubview:_viewController.view]; => calls loadView 
of a child class of NSViewController
[_viewController.view setFrame:_placeholderView.frame];
[_viewController setRepresentedObject:[NSNumber 
numberWithUnsignedLong:[[_viewController.view subviews] count]]];
}


The child class of NSViewController

- (void)loadView
{
[self viewWillLoad];
[super loadView]; <= doesn't return
[self viewDidLoad];
}

Does anyone know why the loadView doesn't return?
Can you spare me your idea?

Thank you.


___

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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Martin Hewitson

On 4, Nov, 2011, at 03:06 PM, Roland King wrote:

> 
> On Nov 4, 2011, at 1:41 PM, Martin Hewitson wrote:
> 
>> 
>> On 4, Nov, 2011, at 02:01 AM, Roland King wrote:
>> 
>>> 
>>> 
>>> 
>>> 
 So, can I conclude from this that iCloud and core-data only works with SQL 
 store? The WWDC video hints at this, but was not explicit.
 
>>> 
>>> Not so. I have a core data app running using icloud and an XML store. This 
>>> is ios by the way and the store is not incremental, it's just being treated 
>>> as a blob which is fully synced each time but it's small so that's ok. 
>>> 
>>> Definitely if you want the incremental log style store you have to use SQL 
>>> but in general core data in iCloud will let you use whatever you like.
>> 
>> I hadn't realised that I had made a choice. How does one choose an 
>> incremental store as opposed to a blob? Any pointers how you got your 
>> core-data iCloud app working would be greatly appreciated!
> 
> Those two keys you add when you open the persistent store, 
> NSPersistentStoreUbiquitousContentNameKey and 
> NSPersistentStoreUbiquitousContentURLKey are the ones which tell Core Data 
> you're using the log file based core data (only available with SQLite). So 
> with that store, the actual SQLite database isn't in the cloud, it's kept 
> local, but a log file directory is created which is in the cloud and deltas 
> are synched up there. The idea is that each client just brings down the log 
> files and updates the database at a record level. Those keys only mean 
> anything with the SQLite store, which may be why you're having issues with 
> migration. I don't use any of those keys, I just have my store as a local 
> file which is synched wholesale. 
> 
> For your original mail, you want to migrate to SQLLite and then also migrate 
> to iCloud. I don't know if you can do that easily in one step. If I were 
> looking at this I would probably think of creating a new SQLLite store for 
> the migration, empty, opening the old local XML store and then migrating the 
> objects over with code. Whether you choose to make the new SQLite store local 
> and then migrate it up to iCloud or make it in the cloud and then update it 
> is a question I don't have a good answer to, I'm still a little confused by 
> how the initial log files get magically created when you migrate a document 
> to iCloud, I'm definitely missing a piece of information somewhere. 

I think I've achieved this migration step with code like this:

NSURL *oldURL = [NSURL fileURLWithPath:[applicationSupportDirectory 
stringByAppendingPathComponent:oldStoreName]];
NSURL *newURL = [NSURL fileURLWithPath:[applicationSupportDirectory 
stringByAppendingPathComponent:storeName]];

persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] 
initWithManagedObjectModel:mom];
if ([fileManager fileExistsAtPath:[oldURL path]]) {
  NSError *error = nil;
  NSPersistentStore *store = [persistentStoreCoordinator 
addPersistentStoreWithType:NSXMLStoreType
  
configuration:nil

URL:oldURL

options:options
  
error:&error];
  if (!store){
[[NSApplication sharedApplication] presentError:error];
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
return nil;
  }


  // now add iCloud options
  [options setObject:storeName 
forKey:NSPersistentStoreUbiquitousContentNameKey];
  NSURL *contentURL = [[NSFileManager defaultManager] 
URLForUbiquityContainerIdentifier:containerID];
  [options setObject:contentURL 
forKey:NSPersistentStoreUbiquitousContentURLKey];  
  [options setObject:[NSNumber numberWithBool:YES] 
forKey:NSValidateXMLStoreOption];

  // migrate it
  store = [persistentStoreCoordinator migratePersistentStore:store toURL:newURL 
options:options withType:NSSQLiteStoreType error:&error];
  if (error) {
[NSApp presentError:error];
return nil;
  }

  // archive old store
  [fileManager moveItemAtURL:oldURL toURL:[oldURL 
URLByAppendingPathExtension:@"xml"] error:&error];
  if (error) {
[NSApp presentError:error];
  }

} else {
  // add iCloud
  [options setObject:storeName 
forKey:NSPersistentStoreUbiquitousContentNameKey];
  NSURL *contentURL = [[NSFileManager defaultManager] 
URLForUbiquityContainerIdentifier:containerID];
  [options setObject:contentURL 
forKey:NSPersistentStoreUbiquitousContentURLKey];  

  // make a new persistent store coordinator
  if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil 
  URL:newURL
  options:options 
 

Re: How to highlight the current line in NSTextView?

2011-11-04 Thread Martin Hewitson
Here's some code that I've been using in an NSTextView subclass. It may be of 
some use.

Martin

- (void) drawViewBackgroundInRect:(NSRect)rect
{
  [super drawViewBackgroundInRect:rect];
  NSRange sel = [self selectedRange];
  NSString *str = [self string];
  if (sel.location <= [str length]) {
NSRange lineRange = [str lineRangeForRange:NSMakeRange(sel.location,0)];
NSRect lineRect = [self highlightRectForRange:lineRange];
NSColor *highlightColor = [NSColor grayColor];
[highlightColor set];
[NSBezierPath fillRect:lineRect];
  }
}

// Returns a rectangle suitable for highlighting a background rectangle for the 
given text range.
- (NSRect) highlightRectForRange:(NSRange)aRange
{
  NSRange r = aRange;
  NSRange startLineRange = [[self string] 
lineRangeForRange:NSMakeRange(r.location, 0)];
  NSInteger er = NSMaxRange(r)-1;
  NSString *text = [self string];
  
  if (er >= [text length]) {
return NSZeroRect;
  }
  if (er < r.location) {
er = r.location;
  }
  
  NSRange endLineRange = [[self string] lineRangeForRange:NSMakeRange(er, 0)];
  
  NSRange gr = [[self layoutManager] 
glyphRangeForCharacterRange:NSMakeRange(startLineRange.location, 
NSMaxRange(endLineRange)-startLineRange.location-1)
actualCharacterRange:NULL];
  NSRect br = [[self layoutManager] boundingRectForGlyphRange:gr 
inTextContainer:[self textContainer]];  
  NSRect b = [self bounds];
  CGFloat h = br.size.height;
  CGFloat w = b.size.width;
  CGFloat y = br.origin.y;  
  NSPoint containerOrigin = [self textContainerOrigin];  
  NSRect aRect = NSMakeRect(0, y, w, h);
  // Convert from view coordinates to container coordinates
  aRect = NSOffsetRect(aRect, containerOrigin.x, containerOrigin.y);
  return aRect;
}


On 4, Nov, 2011, at 04:33 PM, Douglas Davidson wrote:

> The NSLayoutManager will tell you.  Try taking a look at the conceptual 
> documentation and some of the sample code for NSLayoutManager, and let me 
> know if you have any problems.  
> 
> Douglas Davidson
> 
> On Nov 4, 2011, at 6:19 AM, Nick  wrote:
> 
>> Hello
>> Basically the question is about getting the NSRange of the line of
>> NSTextView where the text input cursor is currently in.
>> Word wraps are considered as legal 'new lines' - only one line should
>> actually be highlighted.
>> 
>> How could I do this (get an NSRange of a single line)?
>> Thank you
>> ___
>> 
>> 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/ddavidso%40apple.com
>> 
>> This email sent to ddavi...@apple.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/martin.hewitson%40aei.mpg.de
> 
> This email sent to martin.hewit...@aei.mpg.de


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Martin Hewitson
Roland, thanks for the description. That's useful to know.

But now I seem to have broken the iCloud syncing. Is there a correct way to 
'reset' the cloud for testing purposes? I tried deleting the app container 
under 'Mobile Documents'. First on one machine (machine A), which resulted in 
that machine not receiving the data from the cloud. Then I tried deleting it on 
the other machine (machine B). On this machine when I launch the app, a bunch 
of files and folders are created. But on machine A, nothing much happens in the 
Mobile Documents directory when I launch the app. I'm using the same code-base 
on each machine, so the app should be identical. 

Anyone any idea what could be going on? I don't see any errors in the Console. 
I'd like to reset the two machines and the cloud so that I can start again. 
This seems an essential step when testing.

Thanks in advance for any further insight,

Martin

On 4, Nov, 2011, at 03:06 PM, Roland King wrote:

> 
> On Nov 4, 2011, at 1:41 PM, Martin Hewitson wrote:
> 
>> 
>> On 4, Nov, 2011, at 02:01 AM, Roland King wrote:
>> 
>>> 
>>> 
>>> 
>>> 
 So, can I conclude from this that iCloud and core-data only works with SQL 
 store? The WWDC video hints at this, but was not explicit.
 
>>> 
>>> Not so. I have a core data app running using icloud and an XML store. This 
>>> is ios by the way and the store is not incremental, it's just being treated 
>>> as a blob which is fully synced each time but it's small so that's ok. 
>>> 
>>> Definitely if you want the incremental log style store you have to use SQL 
>>> but in general core data in iCloud will let you use whatever you like.
>> 
>> I hadn't realised that I had made a choice. How does one choose an 
>> incremental store as opposed to a blob? Any pointers how you got your 
>> core-data iCloud app working would be greatly appreciated!
> 
> Those two keys you add when you open the persistent store, 
> NSPersistentStoreUbiquitousContentNameKey and 
> NSPersistentStoreUbiquitousContentURLKey are the ones which tell Core Data 
> you're using the log file based core data (only available with SQLite). So 
> with that store, the actual SQLite database isn't in the cloud, it's kept 
> local, but a log file directory is created which is in the cloud and deltas 
> are synched up there. The idea is that each client just brings down the log 
> files and updates the database at a record level. Those keys only mean 
> anything with the SQLite store, which may be why you're having issues with 
> migration. I don't use any of those keys, I just have my store as a local 
> file which is synched wholesale. 
> 
> For your original mail, you want to migrate to SQLLite and then also migrate 
> to iCloud. I don't know if you can do that easily in one step. If I were 
> looking at this I would probably think of creating a new SQLLite store for 
> the migration, empty, opening the old local XML store and then migrating the 
> objects over with code. Whether you choose to make the new SQLite store local 
> and then migrate it up to iCloud or make it in the cloud and then update it 
> is a question I don't have a good answer to, I'm still a little confused by 
> how the initial log files get magically created when you migrate a document 
> to iCloud, I'm definitely missing a piece of information somewhere. 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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: How to highlight the current line in NSTextView?

2011-11-04 Thread Douglas Davidson
The NSLayoutManager will tell you.  Try taking a look at the conceptual 
documentation and some of the sample code for NSLayoutManager, and let me know 
if you have any problems.  

Douglas Davidson

On Nov 4, 2011, at 6:19 AM, Nick  wrote:

> Hello
> Basically the question is about getting the NSRange of the line of
> NSTextView where the text input cursor is currently in.
> Word wraps are considered as legal 'new lines' - only one line should
> actually be highlighted.
> 
> How could I do this (get an NSRange of a single line)?
> Thank you
> ___
> 
> 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/ddavidso%40apple.com
> 
> This email sent to ddavi...@apple.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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Roland King

On Nov 4, 2011, at 1:41 PM, Martin Hewitson wrote:

> 
> On 4, Nov, 2011, at 02:01 AM, Roland King wrote:
> 
>> 
>> 
>> 
>> 
>>> So, can I conclude from this that iCloud and core-data only works with SQL 
>>> store? The WWDC video hints at this, but was not explicit.
>>> 
>> 
>> Not so. I have a core data app running using icloud and an XML store. This 
>> is ios by the way and the store is not incremental, it's just being treated 
>> as a blob which is fully synced each time but it's small so that's ok. 
>> 
>> Definitely if you want the incremental log style store you have to use SQL 
>> but in general core data in iCloud will let you use whatever you like.
> 
> I hadn't realised that I had made a choice. How does one choose an 
> incremental store as opposed to a blob? Any pointers how you got your 
> core-data iCloud app working would be greatly appreciated!

Those two keys you add when you open the persistent store, 
NSPersistentStoreUbiquitousContentNameKey and 
NSPersistentStoreUbiquitousContentURLKey are the ones which tell Core Data 
you're using the log file based core data (only available with SQLite). So with 
that store, the actual SQLite database isn't in the cloud, it's kept local, but 
a log file directory is created which is in the cloud and deltas are synched up 
there. The idea is that each client just brings down the log files and updates 
the database at a record level. Those keys only mean anything with the SQLite 
store, which may be why you're having issues with migration. I don't use any of 
those keys, I just have my store as a local file which is synched wholesale. 

For your original mail, you want to migrate to SQLLite and then also migrate to 
iCloud. I don't know if you can do that easily in one step. If I were looking 
at this I would probably think of creating a new SQLLite store for the 
migration, empty, opening the old local XML store and then migrating the 
objects over with code. Whether you choose to make the new SQLite store local 
and then migrate it up to iCloud or make it in the cloud and then update it is 
a question I don't have a good answer to, I'm still a little confused by how 
the initial log files get magically created when you migrate a document to 
iCloud, I'm definitely missing a piece of information somewhere. 
___

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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Roland King

On Nov 4, 2011, at 7:39 PM, Mike Abdullah wrote:

> 
> On 4 Nov 2011, at 01:01, Roland King wrote:
> 
>> 
>> 
>> 
>> 
>>> So, can I conclude from this that iCloud and core-data only works with SQL 
>>> store? The WWDC video hints at this, but was not explicit.
>>> 
>> 
>> Not so. I have a core data app running using icloud and an XML store. This 
>> is ios by the way and the store is not incremental, it's just being treated 
>> as a blob which is fully synced each time but it's small so that's ok.
> 
> Well I'm confused, thought iOS didn't support the XML store?
> 

I'm so sorry, I hadn't had my coffee this morning when I wrote that and muddled 
myself up with Martin's mail. I have a binary store on my iOS app. I used it 
because all my databases are really rather small and the binary store doesn't 
suffer the overhead of the SQLite ones, if you have a few 10s of Kb of data for 
each document then binary saves an awful lot of 
space.___

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


How to highlight the current line in NSTextView?

2011-11-04 Thread Nick
Hello
Basically the question is about getting the NSRange of the line of
NSTextView where the text input cursor is currently in.
Word wraps are considered as legal 'new lines' - only one line should
actually be highlighted.

How could I do this (get an NSRange of a single line)?
Thank you
___

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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Martin Hewitson
Sorry, perhaps I wasn't explicit. This is all on OS X, not iOS.

Martin

On Nov 4, 2011, at 12:39 PM, Mike Abdullah wrote:

> 
> On 4 Nov 2011, at 01:01, Roland King wrote:
> 
>> 
>> 
>> 
>> 
>>> So, can I conclude from this that iCloud and core-data only works with SQL 
>>> store? The WWDC video hints at this, but was not explicit.
>>> 
>> 
>> Not so. I have a core data app running using icloud and an XML store. This 
>> is ios by the way and the store is not incremental, it's just being treated 
>> as a blob which is fully synced each time but it's small so that's ok.
> 
> Well I'm confused, thought iOS didn't support the XML store?
> 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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: Adventures in core-data, iCloud, and sandboxing

2011-11-04 Thread Mike Abdullah

On 4 Nov 2011, at 01:01, Roland King wrote:

> 
> 
> 
> 
>> So, can I conclude from this that iCloud and core-data only works with SQL 
>> store? The WWDC video hints at this, but was not explicit.
>> 
> 
> Not so. I have a core data app running using icloud and an XML store. This is 
> ios by the way and the store is not incremental, it's just being treated as a 
> blob which is fully synced each time but it's small so that's ok.

Well I'm confused, thought iOS didn't support the XML store?

___

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: localization nib vs. xib in release build

2011-11-04 Thread Andreas Mayer

Am 04.11.2011 um 00:31 schrieb Alexander Reichstadt:

> What's unexpected are two things:
> - my app still launches in English
> - the English.lproj contains the nib file I localized as e.g. MainMenu.nib, 
> the German.lproj however still contains a MainMenu.xib

Make sure there is no MainMenu.nib in your application's root directory. Those 
nibs will be preferred to the localized ones.

Other than that I can't see any obvious reason why it shouldn't work.


Andreas___

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