Skip to content

Commit

Permalink
remove references to main bundle for cocoapods 0.36. close jessesquir…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Jan 10, 2015
1 parent 3779613 commit eec8ff4
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,58 @@

#import "JSQSystemSoundPlayer+JSQMessages.h"

static NSString * const kJSQMessageReceivedSoundName = @"JSQMessagesAssets.bundle/Sounds/message_received";
static NSString * const kJSQMessageSentSoundName = @"JSQMessagesAssets.bundle/Sounds/message_sent";
#import "JSQMessagesViewController.h"


static NSString * const kJSQMessageReceivedSoundName = @"message_received";
static NSString * const kJSQMessageSentSoundName = @"message_sent";


@implementation JSQSystemSoundPlayer (JSQMessages)

#pragma mark - Public

+ (void)jsq_playMessageReceivedSound
{
[[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:kJSQMessageReceivedSoundName
fileExtension:kJSQSystemSoundTypeAIFF];
[self jsq_playSoundFromJSQMessagesBundleWithName:kJSQMessageReceivedSoundName asAlert:NO];
}

+ (void)jsq_playMessageReceivedAlert
{
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:kJSQMessageReceivedSoundName
fileExtension:kJSQSystemSoundTypeAIFF];
[self jsq_playSoundFromJSQMessagesBundleWithName:kJSQMessageReceivedSoundName asAlert:YES];
}

+ (void)jsq_playMessageSentSound
{
[[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:kJSQMessageSentSoundName
fileExtension:kJSQSystemSoundTypeAIFF];
[self jsq_playSoundFromJSQMessagesBundleWithName:kJSQMessageSentSoundName asAlert:NO];
}

+ (void)jsq_playMessageSentAlert
{
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:kJSQMessageSentSoundName
fileExtension:kJSQSystemSoundTypeAIFF];
[self jsq_playSoundFromJSQMessagesBundleWithName:kJSQMessageSentSoundName asAlert:YES];
}

#pragma mark - Private

+ (void)jsq_playSoundFromJSQMessagesBundleWithName:(NSString *)soundName asAlert:(BOOL)asAlert
{
// save sound player original bundle
NSString *originalPlayerBundleIdentifier = [JSQSystemSoundPlayer sharedPlayer].bundle.bundleIdentifier;

// search for sounds in this library's bundle
[JSQSystemSoundPlayer sharedPlayer].bundle = [NSBundle bundleForClass:[JSQMessagesViewController class]];

NSString *fileName = [NSString stringWithFormat:@"JSQMessagesAssets.bundle/Sounds/%@", soundName];

if (asAlert) {
[[JSQSystemSoundPlayer sharedPlayer] playAlertSoundWithFilename:fileName fileExtension:kJSQSystemSoundTypeAIFF];
}
else {
[[JSQSystemSoundPlayer sharedPlayer] playSoundWithFilename:fileName fileExtension:kJSQSystemSoundTypeAIFF];
}

// restore original bundle
[JSQSystemSoundPlayer sharedPlayer].bundle = [NSBundle bundleWithIdentifier:originalPlayerBundleIdentifier];
}

@end
6 changes: 5 additions & 1 deletion JSQMessagesViewController/Categories/UIImage+JSQMessages.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#import "UIImage+JSQMessages.h"

#import "JSQMessagesViewController.h"


@implementation UIImage (JSQMessages)

- (UIImage *)jsq_imageMaskedWithColor:(UIColor *)maskColor
Expand Down Expand Up @@ -47,7 +50,8 @@ - (UIImage *)jsq_imageMaskedWithColor:(UIColor *)maskColor

+ (UIImage *)jsq_bubbleImageFromBundleWithName:(NSString *)name
{
return [UIImage imageNamed:[NSString stringWithFormat:@"JSQMessagesAssets.bundle/Images/%@", name]];
return [UIImage imageNamed:[NSString stringWithFormat:@"JSQMessagesAssets.bundle/Images/%@", name]
inBundle:[NSBundle bundleForClass:[JSQMessagesViewController class]] compatibleWithTraitCollection:nil];
}

+ (UIImage *)jsq_bubbleRegularImage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ @implementation JSQMessagesViewController
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([JSQMessagesViewController class])
bundle:[NSBundle mainBundle]];
bundle:[NSBundle bundleForClass:[self class]]];
}

+ (instancetype)messagesViewController
{
return [[[self class] alloc] initWithNibName:NSStringFromClass([JSQMessagesViewController class])
bundle:[NSBundle mainBundle]];
bundle:[NSBundle bundleForClass:[self class]]];
}

#pragma mark - Initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ @implementation JSQMessagesCollectionViewCell

+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:[NSBundle mainBundle]];
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:[NSBundle bundleForClass:[self class]]];
}

+ (NSString *)cellReuseIdentifier
Expand Down
4 changes: 3 additions & 1 deletion JSQMessagesViewController/Views/JSQMessagesInputToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ - (void)awakeFromNib
self.jsq_isObserving = NO;
self.sendButtonOnRight = YES;

NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([JSQMessagesToolbarContentView class]) owner:nil options:nil];
NSArray *nibViews = [[NSBundle bundleForClass:[self class]] loadNibNamed:NSStringFromClass([JSQMessagesToolbarContentView class])
owner:nil
options:nil];
JSQMessagesToolbarContentView *toolbarContentView = [nibViews firstObject];
toolbarContentView.frame = self.frame;
[self addSubview:toolbarContentView];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ @implementation JSQMessagesLoadEarlierHeaderView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([JSQMessagesLoadEarlierHeaderView class])
bundle:[NSBundle mainBundle]];
bundle:[NSBundle bundleForClass:[JSQMessagesLoadEarlierHeaderView class]]];
}

+ (NSString *)headerReuseIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ @implementation JSQMessagesToolbarContentView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([JSQMessagesToolbarContentView class])
bundle:[NSBundle mainBundle]];
bundle:[NSBundle bundleForClass:[JSQMessagesToolbarContentView class]]];
}

#pragma mark - Initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ @implementation JSQMessagesTypingIndicatorFooterView
+ (UINib *)nib
{
return [UINib nibWithNibName:NSStringFromClass([JSQMessagesTypingIndicatorFooterView class])
bundle:[NSBundle mainBundle]];
bundle:[NSBundle bundleForClass:[JSQMessagesTypingIndicatorFooterView class]]];
}

+ (NSString *)footerReuseIdentifier
Expand Down

0 comments on commit eec8ff4

Please sign in to comment.