Objective-C and Swift
|
 |
 |
Dear Members,
Is it possible for two apps to simultaneously access microphone under iPhone. We want to develop a Skype recorder for iPhone but need to determine the possibility.
In Android we were getting problem in shared access of microphone but on Windows 7 desktop shared mode for microphone worked.
Thanks,
|
|
|
|
 |
Message Automatically Removed
|
|
|
|
 |
Hello!
I am new to this forum, and new to programming, although I have already reached chapter 18
of Programming in C textbook.
Please, take a look at the program I typed in from the book, and warning messages I receive.
I would be grateful for explanation on what I am doing wrong. I work on Mac OS 10.7.5, Xcode 4.6.3,
Terminal 2.2.3.
1) I created a file with the command:
touch prog18-2.m// Program ot work with fractions - Objective-C version
2) Program
#import
#import
//------ @interface section ---------
@interface Fraction: Object
{
int numerator;
int denominator;
}
-(void) set_numerator: (int) n;
-(void) set_denominator: (int) d;
-(void) print;
@end
// ----- @implementation section -------
@implementation Fraction;
// getters
-(int) numerator
{
return numerator;
}
-(int) denominator
{
return denominator;
}
//setters
-(void) set_numerator: (int) num
{
numerator = num;
}
-(void) set_denominator: (int) denom
{
denominator = denom;
}
//other
-(void) print
{
printf("The value of the fraction is %i/%i\n", numerator, denominator);
}
@end
//-------- program section -----------
int main(void)
{
Fraction* my_fract;
my_fract = [Fraction new];
[my_fract set_numerator: 1];
[my_fract set_denominator: 3];
printf("The numerator is %i, and teh denominator is %i\n", [my_fract numerator], [my_fract denominator]);
[my_fract print];
[my_fract free]; //frees the memory that was used by Fraction object
return 0;
}
3) I compiled it with:
gcc -framework Foundation prog18-2.m -o prog18-2
4) Terminal generated the following:
prog18-2.m: In function ‘main’:
prog18-2.m:58: warning: ‘Fraction’ may not respond to ‘+new’
prog18-2.m:58: warning: (Messages without a matching method signature
prog18-2.m:58: warning: will be assumed to return ‘id’ and accept
prog18-2.m:58: warning: ‘...’ as arguments.)
prog18-2.m:71: warning: ‘Fraction’ may not respond to ‘-free’
Thank you!
|
|
|
|
 |
'Fraction' class is subclass of 'Object'. But 'new' method is available in 'NSObject' class. That is the reason why it its showing warnings for you.
|
|
|
|
 |
Hi
I am getting the below error, when i try to compile xcode project.
duplicate symbol _squareOfDistanceBetweenPoints in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTUtilities.o)
/Users/project/map/libCorePlot-CocoaTouch.a(CPTUtilities.o)
duplicate symbol _niceNum in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTAxis.o)
/Users/project/map/libCorePlot-CocoaTouch.a(CPTAxis.o)
duplicate symbol _AddRoundedRectPath in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTPathExtensions.o)
/Users/project/map/libCorePlot-CocoaTouch.a(CPTPathExtensions.o)
duplicate symbol _CreateRoundedRectPath in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTPathExtensions.o)
/Users/project/map/libCorePlot-CocoaTouch.a(CPTPathExtensions.o)
duplicate symbol _dependentCoord in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTTradingRangePlot.o)
/Users/project/map/libCorePlot-CocoaTouch.a(CPTTradingRangePlot.o)
duplicate symbol _independentCoord in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTTradingRangePlot.o)
/Users/project/map/libCorePlot-CocoaTouch.a(CPTTradingRangePlot.o)
duplicate symbol _MyCGPathApplierFunc in:
/Users/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(NSCoderExtensions.o)
/Users/project/map/libCorePlot-CocoaTouch.a(NSCoderExtensions.o)
ld: 7 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
thanks in advance
|
|
|
|
 |
Hi,
I would like to limit the image taken to fixed size w=5 in and h=10 inch.
1. There is a way to display on screen (when taking the picture) frame in this size?
2. After taking the pic, how to enable moving the picture so the user can center the image in the 5x10 frame
Thanks!
|
|
|
|
 |
I am working on XMPP based project. i am able to send message and it displays in conversation screen but when i receive message it only show in alertview not able to see in conversation screen. help me please.
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(messageReceived:) name:MessageRecivedNotif object:nil];
appdelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
[self getAllMessagesArrayWithOppositeUser:_jid];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardDidShowNotification
object:nil];
}
#pragma mark table delegate and datasource methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tblobj dequeueReusableCellWithIdentifier:@"cell"];
UILabel *lbl;
if (cell==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
if (chatLblRight == 1)
{
lbl = [[UILabel alloc]initWithFrame:CGRectMake(200, 10, 150, 44)];
[lbl setTextColor:[UIColor redColor]];
[cell.contentView addSubview:lbl];
}
}
if (chatLblRight == 1)
{
lbl.text = [[data objectAtIndex:indexPath.row]valueForKey:@"text"];
chatLblRight = 0;
lbl = [[UILabel alloc]initWithFrame:CGRectMake(200, 10, 150, 44)];
[lbl setTextColor:[UIColor redColor]];
[cell.contentView addSubview:lbl];
return cell;
}
else
{
cell.textLabel.text=[[data objectAtIndex:indexPath.row]valueForKey:@"text"];
return cell;
}
}
-(void)messageReceived:(NSNotification*)notif
{
XMPPMessage *message=(XMPPMessage*)notif.object;
NSString *body = [[message elementForName:@"body"] stringValue];
NSMutableDictionary *dic_recive = [[NSMutableDictionary alloc]init];
[dic_recive setObject:body forKey:@"text"];
[data addObject:dic_recive];
chatLblRight = 1;
[tblobj reloadData];
}
-(IBAction)btnsend:(id)sender
{
[txtmsg resignFirstResponder];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
[msgview setFrame:CGRectMake(0, self.view.bounds.size.height-53, self.view.bounds.size.width, 53)];
[UIView commitAnimations];
[((AppDelegate*)[[UIApplication sharedApplication]delegate]) sendMessage:txtmsg.text toUserWithJid:_jid];
NSMutableDictionary *dic_send = [[NSMutableDictionary alloc]init];
[dic_send setObject:txtmsg.text forKey:@"text"];
[data addObject:dic_send];
[tblobj reloadData];
txtmsg.text=@"";
}
-(NSMutableArray *)getAllMessagesArrayWithOppositeUser:(XMPPJID *)xmppUser
{
XMPPMessageArchivingCoreDataStorage *storage = [XMPPMessageArchivingCoreDataStorage sharedInstance];
NSManagedObjectContext *moc = [storage mainThreadManagedObjectContext];
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"XMPPMessageArchiving_Message_CoreDataObject"
inManagedObjectContext:moc];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
[request setEntity:entityDescription];
NSError *error;
NSArray *messages = [moc executeFetchRequest:request error:&error];
data=[[NSMutableArray alloc] init];
@autoreleasepool {
for (XMPPMessageArchiving_Message_CoreDataObject *message in messages) {
if ([message.bareJid isEqual:xmppUser])
{
NSMutableDictionary *dict=[[NSMutableDictionary alloc] init];
[dict setObject:message.body forKey:@"text"];
[dict setObject:message.timestamp forKey:@"date"];
if ([message isOutgoing]) {
[dict setObject:@"1" forKey:@"type"];
[dict setObject:[[message.bareJidStr componentsSeparatedByString:@"@"] firstObject] forKey:@"username"];
[dict setObject:[UIColor greenColor] forKey:@"color"];
}
else{
[dict setObject:@"2" forKey:@"type"];
[dict setObject:[[message.bareJidStr componentsSeparatedByString:@"@"] firstObject] forKey:@"username"];
[dict setObject:[UIColor blueColor] forKey:@"color"];
}
[data addObject:dict];
}
}
}
return data;
}
Where is my mistake ?
EDIT:-
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
{
DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
[[self xmppStream] sendElement:message];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertAction = @"OK";
localNotification.fireDate = [NSDate date];
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
if ([message isChatMessageWithBody])
{
XMPPUserCoreDataStorageObject *user = [xmppRosterStorage userForJID:[message from]
xmppStream:xmppStream
managedObjectContext:[self managedObjectContext_roster]];
NSString *body = [[message elementForName:@"body"] stringValue];
NSString *displayName = [user displayName];
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:displayName
message:body
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}
else
{
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.alertAction = @"Ok";
localNotification.alertBody = [NSString stringWithFormat:@"From: %@\n\n%@",displayName,body];
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
}
}
modified 16-Jun-15 2:45am.
|
|
|
|
 |
Member 11766967 wrote: Where is my mistake ? Could be anywhere. You need to do some debugging for yourself and identify where things are going wrong. Then edit your question and add the detail to explain exactly what is or is not happening that should be. Also please put <pre></pre> tags around your code so people can read it clearly.
|
|
|
|
 |
thanks for your replay. i am new in ios. can you please tell me how i check for received message? i have removed alertview from my didreceivemessage method and then i am not able to received message. i have updated my code of appdelegate.m file and method didreceivemessage. kindly replay. thanks .
|
|
|
|
 |
Member 11766967 wrote: when i receive message it only show in alertview not able to see in conversation screen. help me please.
maybe I am missing something here?? In your didReceiveMessage method you are displaying an alertView when the app is active. otherwise you are displaying it as a notification.
I guess if you don't want to see it in a UIAlertView then maybe you shouldn't use that?
|
|
|
|
|
 |
|
General
News
Suggestion
Question
Bug
Answer
Joke
Praise
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.