I have added ALAssetsLibrary framework to my project and for some reason XCode doesnt detect it.
I have no code completion, and XCode gives a warning and then crashes when I use the following code
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock:^(NSError *error){
NSLog(#"A problem occured");
}];
It doesnt detect what ALAssetsLibrary is and the warning which leads to a crash is
warning: 'ALAssetsLibrary' may not respond to '-enumerateGroupWithTypes:usingBlock:failureBlock:'
Why isnt XCode detecting the framework?
I have added it to my project as well as imported it.
I would really appreciate the help with this, I dont understand what I did wrong. Thanks
Choose "Device", not "Simulator".
First, you're importing AssetsLibrary.h, are you sure this refers to the class ALAssetsLibrary and ALAssetsGroupAlbum?
Second, I'm not sure it failing to find it is the problem, I imagine there would be a different error in that case, such as, this class is not defined, first use in function.
It's saying unrecognized selector, which means there might be a problem with your pointers.
Have you got your SDK set to 3.x? Blocks were only introduced in iOS 4.0, along with all the methods relating to them.
Related
My code suddenly can't be compiled in Xcode 6.1 (I'm sure it's working in Xcode 6 GM and beta version). It shows the error message:
'NSInvocationOperation' is unavailable
My code is:
let operation = NSInvocationOperation(target:self, selector:"backgroundRun:", object:self)
Can anybody help? Thanks.
As of Xcode 6.1, NSInvocation is disabled in Swift, therefore, NSInvocationOperation is disabled too. See this thread in Developer Forum
Because it's not type-safe or ARC-safe. Even in Objective-C it's very very easy to shoot yourself in the foot trying to use it, especially under ARC. Use closures/blocks instead.
You have to use NSBlockOperation in Swift.
or addOperationWithBlock to NSOperationQueue
queue.addOperationWithBlock { [weak self] in
self?.backgroundRun(self)
return
}
I'm using matt gallagaher's AudioStreamer class. I've used it before in a project before ARC came along and it worked fine. When I added the class to a project which uses ARC, I came across lots of errors which I could fix by adding __bridge references etc...
So the app now runs, but when I start the streamer with [streamer start] I keep coming across this error which I don't know how to fix. The compiler stops at the function below in Audiostreamer.m with the error Thread 8: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) - I don't know what to do from here...please help.
if (CFReadStreamSetProperty(stream, kCFStreamPropertyHTTPShouldAutoredirect, kCFBooleanTrue) == false)
{
[self presentAlertWithTitle:NSLocalizedStringFromTable(#"File Error", #"Errors", nil)
message:NSLocalizedStringFromTable(#"Unable to configure network read stream.", #"Errors", nil)];
return NO;
}
I have exactly error with using FreeStreamer by muhku (good library, recommended).
Check that you give correct/not nulled url to AudioStreamer.
Give my StreamingKit library a go. It has the same functionality as AudioStreamer but is built with ARC and has quite a few additionally pieces of functionality.
https://github.com/tumtumtum/StreamingKit
I was getting the same problem, but I disable arc and now is working fine, the only problem that I got is that when I slide my slider I get a new value to seekToTime: , but is not playing starting from the new value. Any idea what that is ?
CoreAudio seems to work internally using exceptions, so if you have an exception breakpoint installed, this is what you will see. Just disable the breakpoints and it'll work.
I read on the web that when I create an object with alloc and init I have to release it (even a NSString), so:
Why if I create a NSString this way:
NSString *prova = [[NSString alloc] init];
[prova release];
I get these errors:
'release' is unavailable: not available in automatic reference counting mode
and
ARC forbids explicit message send of 'release'
on the [prova release] message? I get no error when I try do this:
NSString *prova = [[NSString alloc] init];
NSLog(#"Contenuto 0 di prova: %#", prova);
prova = #"prima prova stringa";
NSLog(#"Contenuto 1 di prova: %#", prova);
prova = #"ma cosè questo fantomatico errore";
NSLog(#"Contenuto 2 di prova: %#", prova);
That's a best practice previous to iOS 5, or in iOS 5 if ARC mode is disabled. Now iOS 5 uses the new Apple's LLVM compiler, which introduces this ARC feature.
So if ARC is enabled (and it is by default), you do not need to use, in general, the release method anymore. You can find more details in documentation.
If you still want to develop the old way, you can add the flag -fno-objc-arc in "Build phases" section of a Xcode project
You are using Apple's new ARC (automatic reference counting). ARC is a new compiler function which adds retain, release and autorelease on compile time automatically.
Have a look at the iOS 5 Release Nodes for more information about ARC: http://developer.apple.com/technologies/ios5/
Automatic Reference Counting (ARC) for Objective-C makes memory management the job of the compiler. By enabling ARC with the new Apple LLVM compiler, you will never need to type retain or release again, dramatically simplifying the development process, while reducing crashes and memory leaks. The compiler has a complete understanding of your objects, and releases each object the instant it is no longer used, so apps run as fast as ever, with predictable, smooth performance.
in ios 5 no need to release objects it automatically release your object.
or another way disable "Objective-C Automatic Reference Counting" ARC from your xcode
ARC is the new feature in IOS5 which means Automatic reference counting... You dont need to look after release and all as you using arc in your app .. You can de-select when you start a new project in the checkbox.
I'm developing an iOS app that is based on ALAssetsLibrary api (available since 4.0), I use it to retrieve all the images and videos saved on the device and it's been pretty simple to do that. Anyway as soon I installed iOS 4.3.4 on my iPhone 4, my code stopped working. The line which invokes the fetching does nothing! The code is the following (and it works fine on iOS 4.3.3):
ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease];
ALAssetsGroupEnumerationResultsBlock assetsEnumerator = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
// handle asset
};
ALAssetsLibraryGroupsEnumerationResultsBlock groupsEnumerator = ^(ALAssetsGroup *group, BOOL *stop) {
// handle group
};
ALAssetsLibraryAccessFailureBlock failHandler = ^(NSError *error) {
// handle error
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:groupsEnumerator failureBlock:failHandler];
it seems that enumerateGroupsWithTypes:usingBlock:failureBlock: never get called, because none of my blocks are executed... and no error is raised! Why? What can I do?
ps: I tried to change "types" argument, but that's not the problem!
I don't understand why (Apple in this moment I'm hating you!), but ALAssetsLibrary in iOS 4.3.4 does not allow fetching in a background thread (I was running a series of NSOperations in a NSOperationQueue).
I solved by creating a little wrapper using performSelectorOnMainThread.
EDIT:
After a code refactoring and the upgrade to iOS 5, I finally realized that the problem is actually related to how ALAssetsLibrary works, there is no need to use performSelectorOnMainThread. I wrote a post on it here.
Something very important:
The user must allow location services for your app.
As written in apple doc for enumerateGroupsWithTypes:usingBlock:failureBlock method.
Special Considerations
This method will fail with error
ALAssetsLibraryAccessGloballyDeniedError if the user has not enabled
Location Services (in Settings > General).
Maybe you should handle this case by displaying an alert to the user.
Hey all, I have a selector that searches the mainBundle for all .aif files, and allows the user to select them. This works fine, but then I removed some of the files from the project and folder, yet they did not disappear. Is there any way to maybe recompile it or something because It's now plagued with sound files that I don't need.
Thanks!
- (void)loadPossibleSounds {
NSBundle *soundBundle = [NSBundle mainBundle];
possDrumSounds = [soundBundle pathsForResourcesOfType:#"aif" inDirectory:nil];
NSLog(#"PossDrumSounds: %#", possDrumSounds);
[possDrumSounds retain];
}
The above is the code that I use to get an array (possDrumSounds) full of all .aif file paths. Looking at it again, it may have to do with the fact that I said inDirectory:nil, but that shouldn't matter.
Try cleaning your target and re-building.
Interestingly, this has been resolved. It appears that for some reason xcode and the iphone simulator retain all of the resources in the bundle. (At least in my case). This was remedied when I tested it on the device which did not have all of the extra sounds.