Prerequisites
- A working iOS quickstart
- An active camera preview
Capture the processed frame
[[NosmaiCore shared] capturePhoto:^(UIImage *image, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (image != nil) {
self.photoPreview.image = image;
return;
}
NSLog(@"Nosmai photo capture failed: %@", error.localizedDescription);
});
}];
The returned image includes the effects visible in the Nosmai preview. The SDK does not save it to Photos automatically.
Save only when requested
Add NSPhotoLibraryAddUsageDescription to Info.plist before saving to the user's photo library. Keep capture and save as separate actions so the user can review or discard the image first.
Verify it worked
Apply a visible effect, capture once, and compare the returned UIImage with the preview. Confirm that the completion block returns no error.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
image is nil | The camera or processing pipeline is not ready | Capture after the processed preview is visible and inspect error |
| Saving to Photos fails | The app is missing photo-library permission | Add NSPhotoLibraryAddUsageDescription and request access before saving |