Re: A question about core data.

2012-04-12 Thread Mike Abdullah
Whoah, back up. It sounds like you've dived in over your depth.

No, you don't have to use an array controller; you are free to modify the 
context as you wish. Using one of Cocoa's built-in controllers might well prove 
better for your task, it's hard to say.

Fetch requests are what they say on the tin; they fetch objects. They do not 
insert them.

I strongly advise you get yourself a decent book on Core Data and learn from 
that.

On 10 Apr 2012, at 23:18, Michael Parchet wrote:

> Hello,
> 
> I have started a billing project with coco and core data. In my project, I 
> have a form that the user must fill to add a customer (for example) but it 
> seems that core data have only an array controller with a manage object 
> context to manage the core data database. Is it true ?
> 
> In some language (such as java), I can send some sql query to the database. 
> such as (insert into Customeer etc..), I can also send a set of query 
> (transaction).
> 
> On the apple website, in a guide, I have reed an information about fetch 
> request How it work ? Can the fetch request help me in my project ?
> 
> Tanks for your help ?
> 
> Best regards
> 
> mparchet
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: A question about core data.

2012-04-12 Thread Felix Franz
Hello Michael, 

On 11.04.2012, at 00:18, Michael Parchet wrote:

> Hello,
> 
> I have started a billing project with coco and core data. In my project, I 
> have a form that the user must fill to add a customer (for example) but it 
> seems that core data have only an array controller with a manage object 
> context to manage the core data database. Is it true ?

no. You don't have to use a NSArrayController. 

> 
> In some language (such as java), I can send some sql query to the database. 
> such as (insert into Customeer etc..), I can also send a set of query 
> (transaction).
> 
> On the apple website, in a guide, I have reed an information about fetch 
> request How it work ? Can the fetch request help me in my project ?

CoreData is a complex technology, if you don't already read the Core Data 
Programming Guide 
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/cdProgrammingGuide.html#//apple_ref/doc/uid/TP40001075
now is the time to do so … 

For example your example "insert a Customer": 

context is a NSManagedObjectContext, "Customer" your Customer entity

NSManagedObject *customer = [NSEntityDescription
insertNewObjectForEntityForName:@"Customer"
inManagedObjectContext:context];

that's all. After that you use the customer. On context>>save: the new customer 
is written to disk (if you don't use a in memory 
persistent store…). 

A fetch request fetches as the name implies … CoreData is not a ORM-framework. 
sqlite is available as a persistent store type, 
but you can't access the database directly. 

Cheers, 

Felix


___

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

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

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

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

Re: Networking and sleep

2012-04-12 Thread Fritz Anderson
On 10 Apr 2012, at 4:41 PM, Lorenzo Thurman wrote:

> I have an app which attempts to make an internet connection after receiving 
> an NSWorkspaceDidWake notification. Most of the time, the connection fails 
> with the error, "...internet connection appears to be offline (-1009)". My 
> guess is the the OS has not yet reinitialized networking before my app 
> attempts to connect. So I added a sleepForInterval:10 to make my app wait a 
> bit before connecting. This seems to work just fine, but question is:
> Is there a more elegant way to handle this? 

Use the (C-level) SCNetworkReachability API to register for callbacks to notify 
you of loss and acquisition of network availability. Search for 
SCNetworkReachabilitySetCallback, and work outward from there.

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

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

Re: Question about hebrew in textfields and textviews

2012-04-12 Thread Kyle Sluder
On Apr 12, 2012, at 12:11 AM, Lee Ann Rucker  wrote:

> That's interesting, because the doc disagrees:
> 
> "Text using NSNaturalTextAlignment is actually displayed using one of the 
> other alignments, depending on the natural alignment of the text’s script."

You're looking at the reference for NSText, not NSTextField.

As I said, I would probably find it surprising if, in an interface designed for 
an LTR language, entering RTL text suddenly changed the alignment of my text 
fields. That could seriously disrupt the readability of a form. (I must note 
that I don't write in any RTL languages.)

Of course it should respect the writing direction, so the cursor would remain 
fixed at the left of the text field while typed characters were appended to the 
left.

For a text view, however, I would definitely want RTL text to be aligned to the 
right.

I would not be surprised if NSTextFieldCell configures its field editor with 
left/right alignment based on the UI direction rather than passing on the 
natural alignment. That might be worth testing.

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

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

Question about block, ARC, self, and reference counting.

2012-04-12 Thread Scott Andrew
I have a question about retain cycles with ARC and blocks.

I have the following code: 

__weak MyViewController* controller = self;

[UIView animateWithDuration:.25 animations:^{
controller.alpha = 0;
}
 completion:^(BOOL finsihed) {
 
   [controller showState];
 }];



-(void) showState {
self.textView.text = self.stateText;
}

I have a question about what happens when I use self in showState. DId i just 
cause a reference counting issue where I now have an extra retain on self and 
it's not going to be cleaned up? The WWDC video say to use weak pointers to 
self in the block otherwise there could be retain cycle issues. This is an 
example. The utility functions are actually quite larger and called from 
multiple places. I'm not creating the strong refrence via a variable because 
these blocks won't be called if self doesn't exist.

Scott
___

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

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

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

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


Re: Question about block, ARC, self, and reference counting.

2012-04-12 Thread Ken Thomases
On Apr 12, 2012, at 12:04 PM, Scott Andrew wrote:

> I have a question about retain cycles with ARC and blocks.
> 
> I have the following code: 
> 
>__weak MyViewController* controller = self;
> 
>[UIView animateWithDuration:.25 animations:^{
>controller.alpha = 0;
>}
> completion:^(BOOL finsihed) {
> 
>   [controller showState];
> }];
> 
> 
> 
> -(void) showState {
>   self.textView.text = self.stateText;
> }
> 
> I have a question about what happens when I use self in showState. DId i just 
> cause a reference counting issue where I now have an extra retain on self and 
> it's not going to be cleaned up?

No.  The compiler looks at the code _in the block_ to know what the block 
should retain.  It doesn't (for this purpose) look inside the -showState 
method.  It can't even reliably know for sure that the call to -showState in 
the block refers to that implementation of -showState.  For example, this code 
could all be called from a superclass which overrides -showState.

> The WWDC video say to use weak pointers to self in the block otherwise there 
> could be retain cycle issues. This is an example. The utility functions are 
> actually quite larger and called from multiple places. I'm not creating the 
> strong refrence via a variable because these blocks won't be called if self 
> doesn't exist.

For this case, you don't even have to worry about referencing self in the 
blocks directly.  You don't need to use the weak copy, controller.  First, the 
object is not itself retaining the blocks.  So, if the blocks retain self, 
that's still not a retain cycle.  Second, the blocks will be disposed of when 
the animation completes.  So any reference they hold on self is released when 
that happens.

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

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


Re: A question about core data.

2012-04-12 Thread Michael Swan
mparchet,
Let Core Data do the heavy lifting for you, that is what it is there for.
If you use an array controller with your UI and set up bindings you can get 
away with out writing any code to make the base of your UI work. 
If I remember correctly you can send your own SQL queries but you can do 
_almost_ anything you need to do easier through Core Data so you should really 
question anytime you start to make your own queries. 
If you need some guidance on using Core Data with a financial related app check 
out my blog @ http:www.theMikeSwan/blog, I wrote a sample app for tracking 
expenses that may be of assistance to you.

As for fetch requests, they are really useful for doing searches of the data.

Above all keep in mind that Core Data is NOT a database, it is a persistence 
framework. If you think of it as a database you will just make your life harder.

Hope this helps,
Mike Swan
ETCP Certified Entertainment Electrician
http://www.theMikeSwan.com


"The Ego is the little self that pretends to be the only self and speaks so 
loudly that the still, small voice of the Greater Self, whose whisperings come 
from within the Soul, are rarely heard - unless we learn to listen."



On 12 Apr, 2012, at 2:23 AM, cocoa-dev-requ...@lists.apple.com wrote:

> Message: 12
> Date: Wed, 11 Apr 2012 00:18:12 +0200
> From: Michael Parchet 
> To: Cocoa-dev@lists.apple.com
> Subject: A question about core data.
> Message-ID: <4f84b1a4.7020...@sunrise.ch>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hello,
> 
> I have started a billing project with coco and core data. In my project, 
> I have a form that the user must fill to add a customer (for example) 
> but it seems that core data have only an array controller with a manage 
> object context to manage the core data database. Is it true ?
> 
> In some language (such as java), I can send some sql query to the 
> database. such as (insert into Customeer etc..), I can also send a set 
> of query (transaction).
> 
> On the apple website, in a guide, I have reed an information about fetch 
> request How it work ? Can the fetch request help me in my project ?
> 
> Tanks for your help ?
> 
> Best regards
> 
> mparchet

___

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

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

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

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


iOS 5: iPod Library Access

2012-04-12 Thread John Michael Zorko

Hello, all ...

I'm trying to navigate the artists / albums / genres / etc. on a device. The 
documentation for this is usually easy to follow, but i'm finding it to be 
confusing regarding the concept of persistent IDs. I've a couple of questions:

1. What does and what does not have an MPMediaItemPropertyPersistentID?
a. Does each artist have one?
b. Does each album have one?
c. Does each genre have one?
d. Does each song / tv show / movie / audiobook / playlist / podcast / 
etc. have one?
e. Are these IDs unique across all collections i.e. will a specific 
album have the same persistent ID of, say, another artist or a song from 
another album?

2. Is it possible to find a particular artist / album / genre / etc. given only 
it's MPMediaItemPropertyPersistentID (assuming 1(e) is true)? If so, how? I see 
lots of examples for finding the albums of an artist, etc. given the artist 
name, album name, etc., but what if two artists have the same name, or 
different artists used the same title for their album? I'd like to use the 
MPMediaItemPropertyPersistentID, if possible, to make each search unambiguous. 
If this is possible, could someone point me at some example code that uses the 
MPMediaItemPropertyPersistentID to find a specific item?

Regards,

John, appreciative


___

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

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

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

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


Re: Question about hebrew in textfields and textviews

2012-04-12 Thread Lee Ann Rucker

On Apr 12, 2012, at 8:12 AM, Kyle Sluder wrote:

> On Apr 12, 2012, at 12:11 AM, Lee Ann Rucker  wrote:
> 
>> That's interesting, because the doc disagrees:
>> 
>> "Text using NSNaturalTextAlignment is actually displayed using one of the 
>> other alignments, depending on the natural alignment of the text’s script."
> 
> You're looking at the reference for NSText, not NSTextField.


OK, there's a [NSControl setAlignment:] that NSTextField inherits, and it takes 
the same values.
 
> 
> As I said, I would probably find it surprising if, in an interface designed 
> for an LTR language, entering RTL text suddenly changed the alignment of my 
> text fields. That could seriously disrupt the readability of a form. (I must 
> note that I don't write in any RTL languages.)
> 
> Of course it should respect the writing direction, so the cursor would remain 
> fixed at the left of the text field while typed characters were appended to 
> the left.
> 
> For a text view, however, I would definitely want RTL text to be aligned to 
> the right.
> 
> I would not be surprised if NSTextFieldCell configures its field editor with 
> left/right alignment based on the UI direction rather than passing on the 
> natural alignment. That might be worth testing.
> 
> --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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Question about block, ARC, self, and reference counting.

2012-04-12 Thread Scott Andrew
Cool. Thank you that was sort of my thought. Then went and watched the WWDC 
video and went into a bit of a panic.

Scott

On Apr 12, 2012, at 11:18 AM, Ken Thomases wrote:

> On Apr 12, 2012, at 12:04 PM, Scott Andrew wrote:
> 
>> I have a question about retain cycles with ARC and blocks.
>> 
>> I have the following code: 
>> 
>>   __weak MyViewController* controller = self;
>> 
>>   [UIView animateWithDuration:.25 animations:^{
>>   controller.alpha = 0;
>>   }
>>completion:^(BOOL finsihed) {
>> 
>>  [controller showState];
>>}];
>> 
>> 
>> 
>> -(void) showState {
>>  self.textView.text = self.stateText;
>> }
>> 
>> I have a question about what happens when I use self in showState. DId i 
>> just cause a reference counting issue where I now have an extra retain on 
>> self and it's not going to be cleaned up?
> 
> No.  The compiler looks at the code _in the block_ to know what the block 
> should retain.  It doesn't (for this purpose) look inside the -showState 
> method.  It can't even reliably know for sure that the call to -showState in 
> the block refers to that implementation of -showState.  For example, this 
> code could all be called from a superclass which overrides -showState.
> 
>> The WWDC video say to use weak pointers to self in the block otherwise there 
>> could be retain cycle issues. This is an example. The utility functions are 
>> actually quite larger and called from multiple places. I'm not creating the 
>> strong refrence via a variable because these blocks won't be called if self 
>> doesn't exist.
> 
> For this case, you don't even have to worry about referencing self in the 
> blocks directly.  You don't need to use the weak copy, controller.  First, 
> the object is not itself retaining the blocks.  So, if the blocks retain 
> self, that's still not a retain cycle.  Second, the blocks will be disposed 
> of when the animation completes.  So any reference they hold on self is 
> released when that happens.
> 
> 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Watching a variable in Xcode 4.3

2012-04-12 Thread Pascal Harris
I've got the weirdest bug.  I have a matrix of views (iOS development, by the 
way) and all of them work correctly except for the object at 0, 0.

The 0,0 view is initialised correctly, but loses its settings at some point 
(although methods that don't rely on those settings still work - the view 
hasn't been deallocated).

There is nothing in my code designed to alter these settings after 
initialisation.  Clearly there's a bug - in order to hunt the bug down I 
thought it'd be a good idea to set a break point when one of the variables 
changes and then see what made the change.  My question is, how do I do this in 
Xcode 4.3?  I'm sure I've done this in the past - but I can't remember how!
___

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

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

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

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


Re: Convert to Objective-C ARC Syntax Error

2012-04-12 Thread Brad Stone
Dave - I am not linking directly to any of the files causing the errors listed 
in my original email.  I did a search on "#import <" and got:
#import 
#import 
#import 
#import 
#import 
#import 
#import  /
#import 
#import 
#import 
#import 
#import 
#import 

On Apr 1, 2012, at 7:16 PM, Dave Zarzycki wrote:

> Brad,
> 
> This looks similar to Radar 10434539. Let me know if this works: simplify the 
> header includes in your code to just #import  and just link 
> against Quartz. If your code is already doing this, then let us know.
> 
> Thanks!
> 
> davez
> 
> 


___

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

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

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

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


iOS 5: iPod Library Access, pt 2

2012-04-12 Thread John Michael Zorko

Hello all,

Is an _artist_ an MPMediaItemCollection of albums, or an MPMediaItem / Entity? 
If the later, how do I get it's MPMediaItemPropertyPersistentID?

Is an _album_ an MPMediaItemCollection of songs, or an MPMediaItem / Entity? If 
the later, how do I get it's MPMediaItemPropertyPersistentID?

... and do the above answers also apply to movies, tv shows, podcasts, 
audiobooks, genres, etc.?

Regards,

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

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


Re: Watching a variable in Xcode 4.3

2012-04-12 Thread Alex Zavatone
You can have an if or case statement where you have a breakpoint set for where 
the condition changes.  

I used to make a method a long time ago called, get this, -(void)breakpoint, 
and have a BP on it, but that's a little overkill.  

switch (myVar) {
case (AllIsWell):
break;
case (AllIsNotWell):
NSLog(@"Breakpoint: check your var");
NSLog(@"MyVarValue: ,%@", thatVarIWantToSee);
// put a BP below
break;
}

In the cases, set up the condition you are looking for that will catch the 
condition you are looking for.  I'm sure you'll need to modify that little 
block a bit, but it should spit out the value of your var after the condition 
is triggered.  

Hope this helps.

On Apr 12, 2012, at 3:02 PM, Pascal Harris wrote:

> I've got the weirdest bug.  I have a matrix of views (iOS development, by the 
> way) and all of them work correctly except for the object at 0, 0.
> 
> The 0,0 view is initialised correctly, but loses its settings at some point 
> (although methods that don't rely on those settings still work - the view 
> hasn't been deallocated).
> 
> There is nothing in my code designed to alter these settings after 
> initialisation.  Clearly there's a bug - in order to hunt the bug down I 
> thought it'd be a good idea to set a break point when one of the variables 
> changes and then see what made the change.  My question is, how do I do this 
> in Xcode 4.3?  I'm sure I've done this in the past - but I can't remember how!
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Watching a variable in Xcode 4.3

2012-04-12 Thread Evadne Wu
http://stackoverflow.com/questions/5632477/where-is-the-expression-window-in-xcode-4
 might help.

On Apr 13, 2012, at 3:02 AM, Pascal Harris <45rpmli...@googlemail.com> wrote:

> I've got the weirdest bug.  I have a matrix of views (iOS development, by the 
> way) and all of them work correctly except for the object at 0, 0.
> 
> The 0,0 view is initialised correctly, but loses its settings at some point 
> (although methods that don't rely on those settings still work - the view 
> hasn't been deallocated).
> 
> There is nothing in my code designed to alter these settings after 
> initialisation.  Clearly there's a bug - in order to hunt the bug down I 
> thought it'd be a good idea to set a break point when one of the variables 
> changes and then see what made the change.  My question is, how do I do this 
> in Xcode 4.3?  I'm sure I've done this in the past - but I can't remember how!
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/ev%40monoceroi.com
> 
> This email sent to e...@monoceroi.com


___

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

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

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

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


Views-based table drag and drop

2012-04-12 Thread Scott Lahteine
Hi,

My app has a views-based table with an NSTableCellView subclass. The 
represented object implements the NSPasteboardReading, NSPasteboardWriting, and 
NSCoding protocols. All the hooks are in place for drag and drop, but I need 
some conceptual help to figure how to implement it properly. I would like to be 
able to drag both within the document window to move rows, and between document 
windows to copy rows.

For dragging within the same document it seemed easiest (at first) to just use 
tableView:writeRowsWithIndexes:toPasteboard: to store the NSIndexSet of the 
selected rows, and then to use that info to move the rows in the document's 
NSMutableArray. But in doing so, I found that draggingImageComponents is no 
longer called on my NSTableCellView subclass. And of course this isn't very 
useful information for dragging objects between documents. So obviously I need 
to use tableView:pasteboardWriterForRow:. But I don't quite understand how this 
behaves internally, or what data I should be returning.

So I have a few questions. First, what should I be returning in 
pasteboardPropertyListForType:? At the moment I'm returning [NSKeyedArchiver 
archivedDataWithRootObject:self]. Since with this option the only data in the 
pasteboard is the archived object, how can I use that to delete the rows from 
their original positions before inserting them at the drop location? (I'm only 
dropping above rows, not on them.) Could I instead return the object pointer in 
pasteboardPropertyListForType: so that I have direct references to the original 
row objects? Should I use the NSTableView's selectedRowIndexes to delete the 
original rows, then unarchive and insert the new instances? Does any of this 
happen automagically, just by virtue of having NSPasteboardReading implemented? 
Should I be using an NSArrayController to save myself the trouble?

Unfortunately the TableViewPlayground sample code isn't very helpful, because 
it doesn't demonstrate dragging custom class objects around, just file urls.

Any and all guidance is much appreciated, especially if you can provide sample 
code for exactly this kind of situation.

--
Scott Lahteine
Thinkyhead Software
___

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

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

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

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


AVAssetWriterInputPixelBufferAdaptor on IOS attempting to write images to a video

2012-04-12 Thread Damien Cooke
HI All,
I am attempting to write out an image as a movie well, it will be an array of 
images but to start with I can't even get one in there.  Any help diagnosing my 
problem would be greatly appreciated.

Here is what I am doing:


//here is the image
NSString *path = [NSString 
stringWithFormat:@"%@/images/0.png",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
 NSUserDomainMask, YES) lastObject]];

NSData *imageData = [[[NSData alloc] initWithContentsOfFile:path] autorelease];
UIImage *uiimage = [UIImage imageWithData:imageData];

//configure the path for the output video
NSString *videoPath = [NSString 
stringWithFormat:@"%@/videos/currentVideo.mov",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
 NSUserDomainMask, YES) lastObject]];

NSError *error = nil;

//create the writer
AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL 
fileURLWithPath:videoPath] fileType:AVFileTypeQuickTimeMovie error:&error];
NSParameterAssert(videoWriter);

//setup the properties for the input
NSDictionary *videoSettings = [NSDictionary 
dictionaryWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,[NSNumber 
numberWithInt:640], AVVideoWidthKey,[NSNumber numberWithInt:960], 
AVVideoHeightKey,nil];

//create the input
AVAssetWriterInput* writerInput = [[AVAssetWriterInput 
assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings] 
retain];

NSParameterAssert(writerInput);
NSParameterAssert([videoWriter canAddInput:writerInput]);
[videoWriter addInput:writerInput];

//configure the properties for the buffer and create the bufferAdaptor
NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA], 
kCVPixelBufferPixelFormatTypeKey, nil];

AVAssetWriterInputPixelBufferAdaptor *adaptor = 
[AVAssetWriterInputPixelBufferAdaptor
 
assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput
 
sourcePixelBufferAttributes:bufferAttributes]; 
//create the pixel buffer

CVPixelBufferRef pixelBuffer = NULL;

CGImageRef cgImage = CGImageCreateCopy([uiimage CGImage]);
CFDataRef image = CGDataProviderCopyData(CGImageGetDataProvider(cgImage));
int status = CVPixelBufferCreateWithBytes(NULL,
  960,
  640,
  kCVPixelFormatType_32BGRA, 
  (void*)CFDataGetBytePtr(image), 
  CGImageGetBytesPerRow(cgImage), 
  NULL, 
  0, 
  NULL, 
  &pixelBuffer);

//write it out
[adaptor appendPixelBuffer:pixelBuffer withPresentationTime:CMTimeMake(2, 60)];



It crashes here reporting

*** Terminating app due to uncaught exception 
'NSInternalInconsistencyException', reason: '*** 
-[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] 
Cannot call method when status is 0'






___

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

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

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

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


Re: Networking and sleep

2012-04-12 Thread Lorenzo Thurman

On Apr 12, 2012, at 9:33 AM, Fritz Anderson wrote:

> On 10 Apr 2012, at 4:41 PM, Lorenzo Thurman wrote:
> 
>> I have an app which attempts to make an internet connection after receiving 
>> an NSWorkspaceDidWake notification. Most of the time, the connection fails 
>> with the error, "...internet connection appears to be offline (-1009)". My 
>> guess is the the OS has not yet reinitialized networking before my app 
>> attempts to connect. So I added a sleepForInterval:10 to make my app wait a 
>> bit before connecting. This seems to work just fine, but question is:
>> Is there a more elegant way to handle this? 
> 
> Use the (C-level) SCNetworkReachability API to register for callbacks to 
> notify you of loss and acquisition of network availability. Search for 
> SCNetworkReachabilitySetCallback, and work outward from there.
> 
>   — F
> 


Great, I'll do that. Thanks!

"...Business! Mankind was my business. The common welfare was my business; 
charity, mercy, forbearance, and benevolence, were all my business. The 
dealings of my trade were but a drop of water in the comprehensive ocean of my 
business!"

Marly's ghost - A Christmas Carol


Lorenzo Thurman
lore...@thethurmans.com




___

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

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

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

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