-(NSManagedObjectContext *)managedObjectContext{
NSManagedObjectContext *context = nil;
id delegate = [[UIApplication sharedApplication]delegate];
if ([delegate performSelector:@selector(managedObjectContext)]) {
context = [delegate managedObjectContext];
}
return context;
}
NSManagedObjectContext *context = [self managedObjectContext];
Humans *newHuman = [NSEntityDescription insertNewObjectForEntityForName:@"Humans"
inManagedObjectContext:[self managedObjectContext]];
if (newHuman != nil) {
newHuman.firstName = self.firstNameField.text;
newHuman.lasteName = self.lastNameField.text;
newHuman.phoneNamber = self.phoneNumberField.text;
}
NSError *savingError = nil;
if (![context save:&savingError]) {
NSLog(@"Eroor");
}
NSManagedObjectContext *context = [self managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc]init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Humans" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSMutableArray *array = [context executeFetchRequest:fetchRequest error:nil]; //Массив можно определить и в другом месте
NSManagedObject *newCell = [self.array objectAtIndex:0]; //Тут надо указать какой-либо индекс (обычно в tableview используется indexPatch.row). Можно так же быстрым перебором получить все.
//И записываем в переменные
NSString *name = [newCell valueForKey:@"firstName"];
NSString *lastName = [newCell valueForKey:@"lasteName"];
NSString *phoneNum = [newCell valueForKey:@"phoneNamber"];
func showSimpleAlert() {
let alert = UIAlertController(title: "Sign out?", message: "You can always access your content by signing back in", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default, handler: { _ in
//Cancel Action
}))
alert.addAction(UIAlertAction(title: "Sign out",
style: UIAlertActionStyle.default,
handler: {(_: UIAlertAction!) in
//Sign out action
}))
self.present(alert, animated: true, completion: nil)
}
func showSimpleActionSheet(controller: UIViewController) {
let alert = UIAlertController(title: "Title", message: "Please Select an Option", preferredStyle: .actionSheet)
alert.addAction(UIAlertAction(title: "Approve", style: .default, handler: { (_) in
print("User click Approve button")
}))
alert.addAction(UIAlertAction(title: "Edit", style: .default, handler: { (_) in
print("User click Edit button")
}))
alert.addAction(UIAlertAction(title: "Delete", style: .destructive, handler: { (_) in
print("User click Delete button")
}))
alert.addAction(UIAlertAction(title: "Dismiss", style: .cancel, handler: { (_) in
print("User click Dismiss button")
}))
self.present(alert, animated: true, completion: {
print("completion block")
})
}
$channel->queue_declare('hello', false, false, false, false);
<?php
$connection = new AMQPConnection(['host'=> '127.0.0.1', 'port' => '5672', 'login' => '', 'password' => '', 'vhost' => 'ejebberd', 'connect_timeout' => 10]);
$connection->connect();
$channel = new AMQPChannel($connection);
$exchangename = IPhonParameters::$rabbit_EXCHANGE;
$queue = 'ejabberd';
$routing_key = 'ejabberd';
$exchange = new AMQPExchange($channel);
$exchange->setName($exchangename);
$exchange->setType(AMQP_EX_TYPE_DIRECT);
$exchange->setFlags(AMQP_DURABLE);
$exchange->declareExchange();
$q = new AMQPQueue($channel);
$q->setName($queue);
$q->setFlags(AMQP_DURABLE);
$q->declareQueue();
$q->bind($exchangename, $routing_key);
for ($i = 1001; $i < 3001 ; $i++) {
$aaa = sprintf('%04d', $i);
$a_body = [
'server' => 'default'
, 'domain' => 'test.com'
, 'action' => 'add'
, 'login' => 'test'.$aaa
, 'password' => 'test'.$aaa
];
$msg_body = json_encode($a_body, JSON_UNESCAPED_UNICODE);
$exchange->publish($msg_body, $routing_key, AMQP_NOPARAM, ['content_type' => 'text/javascript', 'delivery_mode' => 2]);
}
$connection->disconnect();
?>